summaryrefslogtreecommitdiff
authorzecke <zecke>2003-12-20 13:06:29 (UTC)
committer zecke <zecke>2003-12-20 13:06:29 (UTC)
commitd9ffcee06ec97f4a9e00ff0a9071d7a58e5075a1 (patch) (unidiff)
tree1d808cf09131926e6ab6a00e75d9b92182c49365
parentafabf4e4cb1211dd17e0ba0ff77133335d4735b9 (diff)
downloadopie-d9ffcee06ec97f4a9e00ff0a9071d7a58e5075a1.zip
opie-d9ffcee06ec97f4a9e00ff0a9071d7a58e5075a1.tar.gz
opie-d9ffcee06ec97f4a9e00ff0a9071d7a58e5075a1.tar.bz2
Do not use LD_BIND_NOW for now.
I hope ljp gets some numbers for that soon...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/applauncher.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp
index 0ac043b..0db99dd 100644
--- a/core/launcher/applauncher.cpp
+++ b/core/launcher/applauncher.cpp
@@ -531,188 +531,195 @@ bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRais
531 } 531 }
532 532
533#ifdef QT_NO_QWS_MULTIPROCESS 533#ifdef QT_NO_QWS_MULTIPROCESS
534 QMessageBox::warning( 0, tr("Error"), tr("<qt>Could not find the application %1</qt>").arg(c), 534 QMessageBox::warning( 0, tr("Error"), tr("<qt>Could not find the application %1</qt>").arg(c),
535 tr("OK"), 0, 0, 0, 1 ); 535 tr("OK"), 0, 0, 0, 1 );
536#else 536#else
537 537
538 QStrList slist; 538 QStrList slist;
539 unsigned j; 539 unsigned j;
540 for ( j = 0; j < list.count(); j++ ) 540 for ( j = 0; j < list.count(); j++ )
541 slist.append( list[j].utf8() ); 541 slist.append( list[j].utf8() );
542 542
543 const char **args = new const char *[slist.count() + 1]; 543 const char **args = new const char *[slist.count() + 1];
544 for ( j = 0; j < slist.count(); j++ ) 544 for ( j = 0; j < slist.count(); j++ )
545 args[j] = slist.at(j); 545 args[j] = slist.at(j);
546 args[j] = NULL; 546 args[j] = NULL;
547 547
548#ifndef Q_OS_WIN32 548#ifndef Q_OS_WIN32
549#ifdef Q_OS_MACX 549#ifdef Q_OS_MACX
550 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) { 550 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) {
551#else 551#else
552 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) { 552 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) {
553#endif /* Q_OS_MACX */ 553#endif /* Q_OS_MACX */
554 qDebug( "Quick launching: %s", args[0] ); 554 qDebug( "Quick launching: %s", args[0] );
555 if ( getuid() == 0 ) 555 if ( getuid() == 0 )
556 setpriority( PRIO_PROCESS, qlPid, 0 ); 556 setpriority( PRIO_PROCESS, qlPid, 0 );
557 QCString qlch("QPE/QuickLauncher-"); 557 QCString qlch("QPE/QuickLauncher-");
558 qlch += QString::number(qlPid); 558 qlch += QString::number(qlPid);
559 QCopEnvelope env( qlch, "execute(QStrList)" ); 559 QCopEnvelope env( qlch, "execute(QStrList)" );
560 env << slist; 560 env << slist;
561 runningApps[qlPid] = QString(args[0]); 561 runningApps[qlPid] = QString(args[0]);
562 emit launched(qlPid, QString(args[0])); 562 emit launched(qlPid, QString(args[0]));
563 QCopEnvelope e("QPE/System", "busy()"); 563 QCopEnvelope e("QPE/System", "busy()");
564 qlPid = 0; 564 qlPid = 0;
565 qlReady = FALSE; 565 qlReady = FALSE;
566 QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) ); 566 QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) );
567 } else { 567 } else {
568 int pid = ::vfork(); 568 int pid = ::vfork();
569 if ( !pid ) { 569 if ( !pid ) {
570 for ( int fd = 3; fd < 100; fd++ ) 570 for ( int fd = 3; fd < 100; fd++ )
571 ::close( fd ); 571 ::close( fd );
572 ::setpgid( ::getpid(), ::getppid() ); 572 ::setpgid( ::getpid(), ::getppid() );
573 // Try bindir first, so that foo/bar works too 573 // Try bindir first, so that foo/bar works too
574 ::execv( QPEApplication::qpeDir()+"bin/"+args[0], (char * const *)args ); 574 ::execv( QPEApplication::qpeDir()+"bin/"+args[0], (char * const *)args );
575 ::execvp( args[0], (char * const *)args ); 575 ::execvp( args[0], (char * const *)args );
576 _exit( -1 ); 576 _exit( -1 );
577 } 577 }
578 578
579 runningApps[pid] = QString(args[0]); 579 runningApps[pid] = QString(args[0]);
580 emit launched(pid, QString(args[0])); 580 emit launched(pid, QString(args[0]));
581 QCopEnvelope e("QPE/System", "busy()"); 581 QCopEnvelope e("QPE/System", "busy()");
582 } 582 }
583#else 583#else
584 QProcess *proc = new QProcess(this); 584 QProcess *proc = new QProcess(this);
585 if (proc){ 585 if (proc){
586 for (int i=0; i < slist.count(); i++) 586 for (int i=0; i < slist.count(); i++)
587 proc->addArgument(args[i]); 587 proc->addArgument(args[i]);
588 connect(proc, SIGNAL(processExited()), this, SLOT(processExited())); 588 connect(proc, SIGNAL(processExited()), this, SLOT(processExited()));
589 if (!proc->start()){ 589 if (!proc->start()){
590 qDebug("Unable to start application %s", args[0]); 590 qDebug("Unable to start application %s", args[0]);
591 }else{ 591 }else{
592 PROCESS_INFORMATION *procInfo = (PROCESS_INFORMATION *)proc->processIdentifier(); 592 PROCESS_INFORMATION *procInfo = (PROCESS_INFORMATION *)proc->processIdentifier();
593 if (procInfo){ 593 if (procInfo){
594 DWORD pid = procInfo->dwProcessId; 594 DWORD pid = procInfo->dwProcessId;
595 runningApps[pid] = QString(args[0]); 595 runningApps[pid] = QString(args[0]);
596 runningAppsProc.append(proc); 596 runningAppsProc.append(proc);
597 emit launched(pid, QString(args[0])); 597 emit launched(pid, QString(args[0]));
598 QCopEnvelope e("QPE/System", "busy()"); 598 QCopEnvelope e("QPE/System", "busy()");
599 }else{ 599 }else{
600 qDebug("Unable to read process inforation #1 for %s", args[0]); 600 qDebug("Unable to read process inforation #1 for %s", args[0]);
601 } 601 }
602 } 602 }
603 }else{ 603 }else{
604 qDebug("Unable to create process for application %s", args[0]); 604 qDebug("Unable to create process for application %s", args[0]);
605 return FALSE; 605 return FALSE;
606 } 606 }
607#endif 607#endif
608#endif //QT_NO_QWS_MULTIPROCESS 608#endif //QT_NO_QWS_MULTIPROCESS
609 609
610 delete [] args; 610 delete [] args;
611 return TRUE; 611 return TRUE;
612} 612}
613 613
614void AppLauncher::kill( int pid ) 614void AppLauncher::kill( int pid )
615{ 615{
616#ifndef Q_OS_WIN32 616#ifndef Q_OS_WIN32
617 ::kill( pid, SIGTERM ); 617 ::kill( pid, SIGTERM );
618#else 618#else
619 for ( QProcess *proc = runningAppsProc.first(); proc; proc = runningAppsProc.next() ) { 619 for ( QProcess *proc = runningAppsProc.first(); proc; proc = runningAppsProc.next() ) {
620 if ( proc->processIdentifier() == pid ) { 620 if ( proc->processIdentifier() == pid ) {
621 proc->kill(); 621 proc->kill();
622 break; 622 break;
623 } 623 }
624 } 624 }
625#endif 625#endif
626} 626}
627 627
628int AppLauncher::pidForName( const QString &appName ) 628int AppLauncher::pidForName( const QString &appName )
629{ 629{
630 int pid = -1; 630 int pid = -1;
631 631
632 QMap<int, QString>::Iterator it; 632 QMap<int, QString>::Iterator it;
633 for (it = runningApps.begin(); it!= runningApps.end(); ++it) { 633 for (it = runningApps.begin(); it!= runningApps.end(); ++it) {
634 if (*it == appName) { 634 if (*it == appName) {
635 pid = it.key(); 635 pid = it.key();
636 break; 636 break;
637 } 637 }
638 } 638 }
639 639
640 return pid; 640 return pid;
641} 641}
642 642
643void AppLauncher::createQuickLauncher() 643void AppLauncher::createQuickLauncher()
644{ 644{
645 static bool disabled = FALSE; 645 static bool disabled = FALSE;
646 if (disabled) 646 if (disabled)
647 return; 647 return;
648 648
649 qlReady = FALSE; 649 qlReady = FALSE;
650 qlPid = ::vfork(); 650 qlPid = ::vfork();
651 if ( !qlPid ) { 651 if ( !qlPid ) {
652 char **args = new char *[2]; 652 char **args = new char *[2];
653 args[0] = "quicklauncher"; 653 args[0] = "quicklauncher";
654 args[1] = 0; 654 args[1] = 0;
655 for ( int fd = 3; fd < 100; fd++ ) 655 for ( int fd = 3; fd < 100; fd++ )
656 ::close( fd ); 656 ::close( fd );
657 ::setpgid( ::getpid(), ::getppid() ); 657 ::setpgid( ::getpid(), ::getppid() );
658 // Try bindir first, so that foo/bar works too 658 // Try bindir first, so that foo/bar works too
659 setenv( "LD_BIND_NOW", "1", 1 ); 659 /*
660 * LD_BIND_NOW will change the behaviour of ld.so and dlopen
661 * RTLD_LAZY will be made RTLD_NOW which leads to problem
662 * with miscompiled libraries... if LD_BIND_NOW is set.. there
663 * is no way back.. We will wait for numbers from TT to see
664 * if using LD_BIND_NOW is worth it - zecke
665 */
666 //setenv( "LD_BIND_NOW", "1", 1 );
660 ::execv( QPEApplication::qpeDir()+"bin/quicklauncher", args ); 667 ::execv( QPEApplication::qpeDir()+"bin/quicklauncher", args );
661 ::execvp( "quicklauncher", args ); 668 ::execvp( "quicklauncher", args );
662 delete []args; 669 delete []args;
663 disabled = TRUE; 670 disabled = TRUE;
664 _exit( -1 ); 671 _exit( -1 );
665 } else if ( qlPid == -1 ) { 672 } else if ( qlPid == -1 ) {
666 qlPid = 0; 673 qlPid = 0;
667 } else { 674 } else {
668 if ( getuid() == 0 ) 675 if ( getuid() == 0 )
669 setpriority( PRIO_PROCESS, qlPid, 19 ); 676 setpriority( PRIO_PROCESS, qlPid, 19 );
670 } 677 }
671} 678}
672 679
673// Used only by Win32 680// Used only by Win32
674void AppLauncher::processExited() 681void AppLauncher::processExited()
675{ 682{
676#ifdef Q_OS_WIN32 683#ifdef Q_OS_WIN32
677 qDebug("AppLauncher::processExited()"); 684 qDebug("AppLauncher::processExited()");
678 bool found = FALSE; 685 bool found = FALSE;
679 QProcess *proc = (QProcess *) sender(); 686 QProcess *proc = (QProcess *) sender();
680 if (!proc){ 687 if (!proc){
681 qDebug("Interanl error NULL proc"); 688 qDebug("Interanl error NULL proc");
682 return; 689 return;
683 } 690 }
684 691
685 QString appName = proc->arguments()[0]; 692 QString appName = proc->arguments()[0];
686 qDebug("Removing application %s", appName.latin1()); 693 qDebug("Removing application %s", appName.latin1());
687 runningAppsProc.remove(proc); 694 runningAppsProc.remove(proc);
688 695
689 QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName); 696 QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName);
690 if ( hbit != waitingHeartbeat.end() ) { 697 if ( hbit != waitingHeartbeat.end() ) {
691 killTimer( *hbit ); 698 killTimer( *hbit );
692 waitingHeartbeat.remove( hbit ); 699 waitingHeartbeat.remove( hbit );
693 } 700 }
694 if ( appName == appKillerName ) { 701 if ( appName == appKillerName ) {
695 appKillerName = QString::null; 702 appKillerName = QString::null;
696 delete appKillerBox; 703 delete appKillerBox;
697 appKillerBox = 0; 704 appKillerBox = 0;
698 } 705 }
699 706
700 // Search for the app to find its PID 707 // Search for the app to find its PID
701 QMap<int, QString>::Iterator it; 708 QMap<int, QString>::Iterator it;
702 for (it = runningApps.begin(); it!= runningApps.end(); ++it){ 709 for (it = runningApps.begin(); it!= runningApps.end(); ++it){
703 if (it.data() == appName){ 710 if (it.data() == appName){
704 found = TRUE; 711 found = TRUE;
705 break; 712 break;
706 } 713 }
707 } 714 }
708 715
709 if (found){ 716 if (found){
710 emit terminated(it.key(), it.data()); 717 emit terminated(it.key(), it.data());
711 runningApps.remove(it.key()); 718 runningApps.remove(it.key());
712 }else{ 719 }else{
713 qDebug("Internal error application %s not listed as running", appName.latin1()); 720 qDebug("Internal error application %s not listed as running", appName.latin1());
714 } 721 }
715 722
716#endif 723#endif
717} 724}
718 725