author | mickeyl <mickeyl> | 2004-02-24 16:19:56 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-24 16:19:56 (UTC) |
commit | e3e4d0cca07dfa5487acb54596ac978f2343fc40 (patch) (unidiff) | |
tree | 1b995ed3b874b8f3ac55311ea516ded3a81e469f | |
parent | 607c6aff17cd1c26d36b94d8e7ef149cfed70142 (diff) | |
download | opie-e3e4d0cca07dfa5487acb54596ac978f2343fc40.zip opie-e3e4d0cca07dfa5487acb54596ac978f2343fc40.tar.gz opie-e3e4d0cca07dfa5487acb54596ac978f2343fc40.tar.bz2 |
why not tell us something informative when you're telling us something anyway?
-rw-r--r-- | core/launcher/applauncher.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp index a8779a5..c3584ad 100644 --- a/core/launcher/applauncher.cpp +++ b/core/launcher/applauncher.cpp | |||
@@ -359,257 +359,257 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus) | |||
359 | cfg.setGroup("Preload"); | 359 | cfg.setGroup("Preload"); |
360 | QStringList apps = cfg.readListEntry("Apps",','); | 360 | QStringList apps = cfg.readListEntry("Apps",','); |
361 | QString exe = app->exec(); | 361 | QString exe = app->exec(); |
362 | apps.remove(exe); | 362 | apps.remove(exe); |
363 | cfg.writeEntry("Apps",apps,','); | 363 | cfg.writeEntry("Apps",apps,','); |
364 | preloadDisabled = TRUE; | 364 | preloadDisabled = TRUE; |
365 | } | 365 | } |
366 | 366 | ||
367 | // clean up | 367 | // clean up |
368 | if ( exitStatus ) { | 368 | if ( exitStatus ) { |
369 | QCopEnvelope e("QPE/System", "notBusy(QString)"); | 369 | QCopEnvelope e("QPE/System", "notBusy(QString)"); |
370 | e << app->exec(); | 370 | e << app->exec(); |
371 | } | 371 | } |
372 | /* | 372 | /* |
373 | // debug info | 373 | // debug info |
374 | for (it = runningApps.begin(); it != runningApps.end(); ++it) { | 374 | for (it = runningApps.begin(); it != runningApps.end(); ++it) { |
375 | qDebug("running according to internal list: %s, with pid %d", (*it).data(), it.key() ); | 375 | qDebug("running according to internal list: %s, with pid %d", (*it).data(), it.key() ); |
376 | } | 376 | } |
377 | */ | 377 | */ |
378 | 378 | ||
379 | #ifdef QTOPIA_PROGRAM_MONITOR | 379 | #ifdef QTOPIA_PROGRAM_MONITOR |
380 | if ( crashed ) { | 380 | if ( crashed ) { |
381 | QString sig; | 381 | QString sig; |
382 | switch( exitStatus ) { | 382 | switch( exitStatus ) { |
383 | case SIGABRT: sig = "SIGABRT"; break; | 383 | case SIGABRT: sig = "SIGABRT"; break; |
384 | case SIGALRM: sig = "SIGALRM"; break; | 384 | case SIGALRM: sig = "SIGALRM"; break; |
385 | case SIGBUS: sig = "SIGBUS"; break; | 385 | case SIGBUS: sig = "SIGBUS"; break; |
386 | case SIGFPE: sig = "SIGFPE"; break; | 386 | case SIGFPE: sig = "SIGFPE"; break; |
387 | case SIGHUP: sig = "SIGHUP"; break; | 387 | case SIGHUP: sig = "SIGHUP"; break; |
388 | case SIGILL: sig = "SIGILL"; break; | 388 | case SIGILL: sig = "SIGILL"; break; |
389 | case SIGKILL: sig = "SIGKILL"; break; | 389 | case SIGKILL: sig = "SIGKILL"; break; |
390 | case SIGPIPE: sig = "SIGPIPE"; break; | 390 | case SIGPIPE: sig = "SIGPIPE"; break; |
391 | case SIGQUIT: sig = "SIGQUIT"; break; | 391 | case SIGQUIT: sig = "SIGQUIT"; break; |
392 | case SIGSEGV: sig = "SIGSEGV"; break; | 392 | case SIGSEGV: sig = "SIGSEGV"; break; |
393 | case SIGTERM: sig = "SIGTERM"; break; | 393 | case SIGTERM: sig = "SIGTERM"; break; |
394 | case SIGTRAP: sig = "SIGTRAP"; break; | 394 | case SIGTRAP: sig = "SIGTRAP"; break; |
395 | default: sig = QString("Unkown %1").arg(exitStatus); | 395 | default: sig = QString("Unkown %1").arg(exitStatus); |
396 | } | 396 | } |
397 | if ( preloadDisabled ) | 397 | if ( preloadDisabled ) |
398 | sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>"); | 398 | sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>"); |
399 | 399 | ||
400 | QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig ); | 400 | QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig ); |
401 | QMessageBox::information(0, tr("Application terminated"), str ); | 401 | QMessageBox::information(0, tr("Application terminated"), str ); |
402 | } else { | 402 | } else { |
403 | if ( exitStatus == 255 ) { //could not find app (because global returns -1) | 403 | if ( exitStatus == 255 ) { //could not find app (because global returns -1) |
404 | QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) ); | 404 | QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) ); |
405 | } else { | 405 | } else { |
406 | QFileInfo fi(QString::fromLatin1("/tmp/qcop-msg-") + appName); | 406 | QFileInfo fi(QString::fromLatin1("/tmp/qcop-msg-") + appName); |
407 | if ( fi.exists() && fi.size() ) { | 407 | if ( fi.exists() && fi.size() ) { |
408 | emit terminated(sigPid, appName); | 408 | emit terminated(sigPid, appName); |
409 | qWarning("Re executing obmitted for %s", appName.latin1() ); | 409 | qWarning("Re executing obmitted for %s", appName.latin1() ); |
410 | // execute( appName, QString::null ); | 410 | // execute( appName, QString::null ); |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | } | 413 | } |
414 | } | 414 | } |
415 | 415 | ||
416 | #endif | 416 | #endif |
417 | 417 | ||
418 | emit terminated(sigPid, appName); | 418 | emit terminated(sigPid, appName); |
419 | } | 419 | } |
420 | #else | 420 | #else |
421 | void AppLauncher::sigStopped(int sigPid, int sigStatus) | 421 | void AppLauncher::sigStopped(int sigPid, int sigStatus) |
422 | { | 422 | { |
423 | qDebug("Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)"); | 423 | qDebug("Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)"); |
424 | } | 424 | } |
425 | #endif // Q_OS_WIN32 | 425 | #endif // Q_OS_WIN32 |
426 | 426 | ||
427 | bool AppLauncher::isRunning(const QString &app) | 427 | bool AppLauncher::isRunning(const QString &app) |
428 | { | 428 | { |
429 | for (QMap<int,QString>::ConstIterator it = runningApps.begin(); it != runningApps.end(); ++it) { | 429 | for (QMap<int,QString>::ConstIterator it = runningApps.begin(); it != runningApps.end(); ++it) { |
430 | if ( *it == app ) { | 430 | if ( *it == app ) { |
431 | #ifdef Q_OS_UNIX | 431 | #ifdef Q_OS_UNIX |
432 | pid_t t = ::__getpgid( it.key() ); | 432 | pid_t t = ::__getpgid( it.key() ); |
433 | if ( t == -1 ) { | 433 | if ( t == -1 ) { |
434 | qDebug("appLauncher bug, %s believed running, but pid %d is not existing", app.data(), it.key() ); | 434 | qDebug("appLauncher bug, %s believed running, but pid %d is not existing", app.data(), it.key() ); |
435 | runningApps.remove( it.key() ); | 435 | runningApps.remove( it.key() ); |
436 | return FALSE; | 436 | return FALSE; |
437 | } | 437 | } |
438 | #endif | 438 | #endif |
439 | return TRUE; | 439 | return TRUE; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | return FALSE; | 443 | return FALSE; |
444 | } | 444 | } |
445 | 445 | ||
446 | bool AppLauncher::executeBuiltin(const QString &c, const QString &document) | 446 | bool AppLauncher::executeBuiltin(const QString &c, const QString &document) |
447 | { | 447 | { |
448 | Global::Command* builtin = OGlobal::builtinCommands(); | 448 | Global::Command* builtin = OGlobal::builtinCommands(); |
449 | QGuardedPtr<QWidget> *running = OGlobal::builtinRunning(); | 449 | QGuardedPtr<QWidget> *running = OGlobal::builtinRunning(); |
450 | 450 | ||
451 | // Attempt to execute the app using a builtin class for the app | 451 | // Attempt to execute the app using a builtin class for the app |
452 | if (builtin) { | 452 | if (builtin) { |
453 | for (int i = 0; builtin[i].file; i++) { | 453 | for (int i = 0; builtin[i].file; i++) { |
454 | if ( builtin[i].file == c ) { | 454 | if ( builtin[i].file == c ) { |
455 | if ( running[i] ) { | 455 | if ( running[i] ) { |
456 | if ( !document.isNull() && builtin[i].documentary ) | 456 | if ( !document.isNull() && builtin[i].documentary ) |
457 | Global::setDocument(running[i], document); | 457 | Global::setDocument(running[i], document); |
458 | running[i]->raise(); | 458 | running[i]->raise(); |
459 | running[i]->show(); | 459 | running[i]->show(); |
460 | running[i]->setActiveWindow(); | 460 | running[i]->setActiveWindow(); |
461 | } else { | 461 | } else { |
462 | running[i] = builtin[i].func( builtin[i].maximized ); | 462 | running[i] = builtin[i].func( builtin[i].maximized ); |
463 | } | 463 | } |
464 | #ifndef QT_NO_COP | 464 | #ifndef QT_NO_COP |
465 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 465 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
466 | e << c; // that was quick ;-) | 466 | e << c; // that was quick ;-) |
467 | #endif | 467 | #endif |
468 | return TRUE; | 468 | return TRUE; |
469 | } | 469 | } |
470 | } | 470 | } |
471 | } | 471 | } |
472 | 472 | ||
473 | // Convert the command line in to a list of arguments | 473 | // Convert the command line in to a list of arguments |
474 | QStringList list = QStringList::split(QRegExp(" *"),c); | 474 | QStringList list = QStringList::split(QRegExp(" *"),c); |
475 | QString ap=list[0]; | 475 | QString ap=list[0]; |
476 | 476 | ||
477 | if ( ap == "suspend" ) { // No tr | 477 | if ( ap == "suspend" ) { // No tr |
478 | QWSServer::processKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 478 | QWSServer::processKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
479 | return TRUE; | 479 | return TRUE; |
480 | } | 480 | } |
481 | 481 | ||
482 | return FALSE; | 482 | return FALSE; |
483 | } | 483 | } |
484 | 484 | ||
485 | bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise) | 485 | bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise) |
486 | { | 486 | { |
487 | qWarning("AppLauncher::execute"); | 487 | qWarning("AppLauncher::execute '%s' '%s'", (const char*) c, (const char*) docParam ); |
488 | // Convert the command line in to a list of arguments | 488 | // Convert the command line in to a list of arguments |
489 | QStringList list = QStringList::split(QRegExp(" *"),c); | 489 | QStringList list = QStringList::split(QRegExp(" *"),c); |
490 | if ( !docParam.isEmpty() ) | 490 | if ( !docParam.isEmpty() ) |
491 | list.append( docParam ); | 491 | list.append( docParam ); |
492 | 492 | ||
493 | QString appName = list[0]; | 493 | QString appName = list[0]; |
494 | if ( isRunning(appName) ) { | 494 | if ( isRunning(appName) ) { |
495 | QCString channel = "QPE/Application/"; | 495 | QCString channel = "QPE/Application/"; |
496 | channel += appName.latin1(); | 496 | channel += appName.latin1(); |
497 | 497 | ||
498 | // Need to lock it to avoid race conditions with QPEApplication::processQCopFile | 498 | // Need to lock it to avoid race conditions with QPEApplication::processQCopFile |
499 | QFile f(QString::fromLatin1("/tmp/qcop-msg-") + appName); | 499 | QFile f(QString::fromLatin1("/tmp/qcop-msg-") + appName); |
500 | if ( !noRaise && f.open(IO_WriteOnly | IO_Append) ) { | 500 | if ( !noRaise && f.open(IO_WriteOnly | IO_Append) ) { |
501 | #ifndef Q_OS_WIN32 | 501 | #ifndef Q_OS_WIN32 |
502 | flock(f.handle(), LOCK_EX); | 502 | flock(f.handle(), LOCK_EX); |
503 | #endif | 503 | #endif |
504 | 504 | ||
505 | QDataStream ds(&f); | 505 | QDataStream ds(&f); |
506 | QByteArray b; | 506 | QByteArray b; |
507 | QDataStream bstream(b, IO_WriteOnly); | 507 | QDataStream bstream(b, IO_WriteOnly); |
508 | if ( !f.size() ) { | 508 | if ( !f.size() ) { |
509 | ds << channel << QCString("raise()") << b; | 509 | ds << channel << QCString("raise()") << b; |
510 | if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { | 510 | if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { |
511 | int id = startTimer(RAISE_TIMEOUT_MS); | 511 | int id = startTimer(RAISE_TIMEOUT_MS); |
512 | waitingHeartbeat.insert( appName, id ); | 512 | waitingHeartbeat.insert( appName, id ); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | if ( !docParam.isEmpty() ) { | 515 | if ( !docParam.isEmpty() ) { |
516 | bstream << docParam; | 516 | bstream << docParam; |
517 | ds << channel << QCString("setDocument(QString)") << b; | 517 | ds << channel << QCString("setDocument(QString)") << b; |
518 | } | 518 | } |
519 | 519 | ||
520 | f.flush(); | 520 | f.flush(); |
521 | #ifndef Q_OS_WIN32 | 521 | #ifndef Q_OS_WIN32 |
522 | flock(f.handle(), LOCK_UN); | 522 | flock(f.handle(), LOCK_UN); |
523 | #endif | 523 | #endif |
524 | f.close(); | 524 | f.close(); |
525 | } | 525 | } |
526 | if ( QCopChannel::isRegistered(channel) ) // avoid unnecessary warnings | 526 | if ( QCopChannel::isRegistered(channel) ) // avoid unnecessary warnings |
527 | QCopChannel::send(channel,"QPEProcessQCop()"); | 527 | QCopChannel::send(channel,"QPEProcessQCop()"); |
528 | 528 | ||
529 | return TRUE; | 529 | return TRUE; |
530 | } | 530 | } |
531 | 531 | ||
532 | #ifdef QT_NO_QWS_MULTIPROCESS | 532 | #ifdef QT_NO_QWS_MULTIPROCESS |
533 | QMessageBox::warning( 0, tr("Error"), tr("<qt>Could not find the application %1</qt>").arg(c), | 533 | QMessageBox::warning( 0, tr("Error"), tr("<qt>Could not find the application %1</qt>").arg(c), |
534 | tr("OK"), 0, 0, 0, 1 ); | 534 | tr("OK"), 0, 0, 0, 1 ); |
535 | #else | 535 | #else |
536 | 536 | ||
537 | QStrList slist; | 537 | QStrList slist; |
538 | unsigned j; | 538 | unsigned j; |
539 | for ( j = 0; j < list.count(); j++ ) | 539 | for ( j = 0; j < list.count(); j++ ) |
540 | slist.append( list[j].utf8() ); | 540 | slist.append( list[j].utf8() ); |
541 | 541 | ||
542 | const char **args = new const char *[slist.count() + 1]; | 542 | const char **args = new const char *[slist.count() + 1]; |
543 | for ( j = 0; j < slist.count(); j++ ) | 543 | for ( j = 0; j < slist.count(); j++ ) |
544 | args[j] = slist.at(j); | 544 | args[j] = slist.at(j); |
545 | args[j] = NULL; | 545 | args[j] = NULL; |
546 | 546 | ||
547 | #ifndef Q_OS_WIN32 | 547 | #ifndef Q_OS_WIN32 |
548 | #ifdef Q_OS_MACX | 548 | #ifdef Q_OS_MACX |
549 | if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) { | 549 | if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) { |
550 | #else | 550 | #else |
551 | if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) { | 551 | if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) { |
552 | #endif /* Q_OS_MACX */ | 552 | #endif /* Q_OS_MACX */ |
553 | qDebug( "Quick launching: %s", args[0] ); | 553 | qDebug( "Quick launching: %s", args[0] ); |
554 | if ( getuid() == 0 ) | 554 | if ( getuid() == 0 ) |
555 | setpriority( PRIO_PROCESS, qlPid, 0 ); | 555 | setpriority( PRIO_PROCESS, qlPid, 0 ); |
556 | QCString qlch("QPE/QuickLauncher-"); | 556 | QCString qlch("QPE/QuickLauncher-"); |
557 | qlch += QString::number(qlPid); | 557 | qlch += QString::number(qlPid); |
558 | QCopEnvelope env( qlch, "execute(QStrList)" ); | 558 | QCopEnvelope env( qlch, "execute(QStrList)" ); |
559 | env << slist; | 559 | env << slist; |
560 | runningApps[qlPid] = QString(args[0]); | 560 | runningApps[qlPid] = QString(args[0]); |
561 | emit launched(qlPid, QString(args[0])); | 561 | emit launched(qlPid, QString(args[0])); |
562 | QCopEnvelope e("QPE/System", "busy()"); | 562 | QCopEnvelope e("QPE/System", "busy()"); |
563 | qlPid = 0; | 563 | qlPid = 0; |
564 | qlReady = FALSE; | 564 | qlReady = FALSE; |
565 | QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) ); | 565 | QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) ); |
566 | } else { | 566 | } else { |
567 | int pid = ::vfork(); | 567 | int pid = ::vfork(); |
568 | if ( !pid ) { | 568 | if ( !pid ) { |
569 | for ( int fd = 3; fd < 100; fd++ ) | 569 | for ( int fd = 3; fd < 100; fd++ ) |
570 | ::close( fd ); | 570 | ::close( fd ); |
571 | ::setpgid( ::getpid(), ::getppid() ); | 571 | ::setpgid( ::getpid(), ::getppid() ); |
572 | // Try bindir first, so that foo/bar works too | 572 | // Try bindir first, so that foo/bar works too |
573 | ::execv( QPEApplication::qpeDir()+"bin/"+args[0], (char * const *)args ); | 573 | ::execv( QPEApplication::qpeDir()+"bin/"+args[0], (char * const *)args ); |
574 | ::execvp( args[0], (char * const *)args ); | 574 | ::execvp( args[0], (char * const *)args ); |
575 | _exit( -1 ); | 575 | _exit( -1 ); |
576 | } | 576 | } |
577 | 577 | ||
578 | runningApps[pid] = QString(args[0]); | 578 | runningApps[pid] = QString(args[0]); |
579 | emit launched(pid, QString(args[0])); | 579 | emit launched(pid, QString(args[0])); |
580 | QCopEnvelope e("QPE/System", "busy()"); | 580 | QCopEnvelope e("QPE/System", "busy()"); |
581 | } | 581 | } |
582 | #else | 582 | #else |
583 | QProcess *proc = new QProcess(this); | 583 | QProcess *proc = new QProcess(this); |
584 | if (proc){ | 584 | if (proc){ |
585 | for (int i=0; i < slist.count(); i++) | 585 | for (int i=0; i < slist.count(); i++) |
586 | proc->addArgument(args[i]); | 586 | proc->addArgument(args[i]); |
587 | connect(proc, SIGNAL(processExited()), this, SLOT(processExited())); | 587 | connect(proc, SIGNAL(processExited()), this, SLOT(processExited())); |
588 | if (!proc->start()){ | 588 | if (!proc->start()){ |
589 | qDebug("Unable to start application %s", args[0]); | 589 | qDebug("Unable to start application %s", args[0]); |
590 | }else{ | 590 | }else{ |
591 | PROCESS_INFORMATION *procInfo = (PROCESS_INFORMATION *)proc->processIdentifier(); | 591 | PROCESS_INFORMATION *procInfo = (PROCESS_INFORMATION *)proc->processIdentifier(); |
592 | if (procInfo){ | 592 | if (procInfo){ |
593 | DWORD pid = procInfo->dwProcessId; | 593 | DWORD pid = procInfo->dwProcessId; |
594 | runningApps[pid] = QString(args[0]); | 594 | runningApps[pid] = QString(args[0]); |
595 | runningAppsProc.append(proc); | 595 | runningAppsProc.append(proc); |
596 | emit launched(pid, QString(args[0])); | 596 | emit launched(pid, QString(args[0])); |
597 | QCopEnvelope e("QPE/System", "busy()"); | 597 | QCopEnvelope e("QPE/System", "busy()"); |
598 | }else{ | 598 | }else{ |
599 | qDebug("Unable to read process inforation #1 for %s", args[0]); | 599 | qDebug("Unable to read process inforation #1 for %s", args[0]); |
600 | } | 600 | } |
601 | } | 601 | } |
602 | }else{ | 602 | }else{ |
603 | qDebug("Unable to create process for application %s", args[0]); | 603 | qDebug("Unable to create process for application %s", args[0]); |
604 | return FALSE; | 604 | return FALSE; |
605 | } | 605 | } |
606 | #endif | 606 | #endif |
607 | #endif //QT_NO_QWS_MULTIPROCESS | 607 | #endif //QT_NO_QWS_MULTIPROCESS |
608 | 608 | ||
609 | delete [] args; | 609 | delete [] args; |
610 | return TRUE; | 610 | return TRUE; |
611 | } | 611 | } |
612 | 612 | ||
613 | void AppLauncher::kill( int pid ) | 613 | void AppLauncher::kill( int pid ) |
614 | { | 614 | { |
615 | #ifndef Q_OS_WIN32 | 615 | #ifndef Q_OS_WIN32 |