author | sandman <sandman> | 2002-08-04 02:25:54 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-04 02:25:54 (UTC) |
commit | 8fd0780faa16abbcf7db9220af1bc333ae484ec8 (patch) (unidiff) | |
tree | ffacd596daa0ab07890f185510275667649d55db /core | |
parent | 549df674d7af9fe1347751e6a63d6ed8249d2503 (diff) | |
download | opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.zip opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.tar.gz opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.tar.bz2 |
1) Fixes for suspend/resume (improved it for iPAQ, shouldn't have changed
anything for Z) -- It seems that this also fixes the 70% CPU load
problem (needs more testing/feedback though)
2) the launcher now creates a /var/run/opie.pid file containing its pid
3) the launcher catches SIGTERM and kills all its child processes
-rw-r--r-- | core/launcher/desktop.cpp | 58 | ||||
-rw-r--r-- | core/launcher/main.cpp | 42 |
2 files changed, 70 insertions, 30 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index f90da1a..7f24259 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -604,30 +604,40 @@ static void darkScreen() | |||
604 | 604 | ||
605 | void Desktop::togglePower() | 605 | void Desktop::togglePower() |
606 | { | 606 | { |
607 | bool wasloggedin = loggedin; | 607 | static bool excllock = false; |
608 | loggedin=0; | 608 | |
609 | suspendTime = QDateTime::currentDateTime(); | 609 | if ( excllock ) |
610 | darkScreen(); | 610 | return; |
611 | if ( wasloggedin ) | 611 | |
612 | blankScreen(); | 612 | excllock = true; |
613 | 613 | ||
614 | system("apm --suspend"); | 614 | bool wasloggedin = loggedin; |
615 | 615 | loggedin=0; | |
616 | 616 | suspendTime = QDateTime::currentDateTime(); | |
617 | 617 | darkScreen(); | |
618 | QWSServer::screenSaverActivate( FALSE ); | 618 | if ( wasloggedin ) |
619 | { | 619 | blankScreen(); |
620 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 620 | |
621 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 621 | ODevice::inst ( )-> suspend ( ); |
622 | e << -3; // Force on | 622 | |
623 | } | 623 | QWSServer::screenSaverActivate( FALSE ); |
624 | if ( wasloggedin ) { | 624 | |
625 | login(TRUE); | 625 | { |
626 | } | 626 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
627 | sleep(1); | 627 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
628 | execAutoStart(); | 628 | e << -3; // Force on |
629 | //qcopBridge->closeOpenConnections(); | 629 | } |
630 | //qDebug("called togglePower()!!!!!!"); | 630 | |
631 | if ( wasloggedin ) | ||
632 | login(TRUE); | ||
633 | |||
634 | execAutoStart(); | ||
635 | //qcopBridge->closeOpenConnections(); | ||
636 | //qDebug("called togglePower()!!!!!!"); | ||
637 | |||
638 | qApp-> processEvents ( ); | ||
639 | |||
640 | excllock = false; | ||
631 | } | 641 | } |
632 | 642 | ||
633 | void Desktop::toggleLight() | 643 | void Desktop::toggleLight() |
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index a19da14..1e741d5 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -333,20 +333,50 @@ int initApplication( int argc, char ** argv ) | |||
333 | return rv; | 333 | return rv; |
334 | } | 334 | } |
335 | 335 | ||
336 | static const char *pidfile_path = "/var/run/opie.pid"; | ||
337 | |||
338 | void create_pidfile ( ) | ||
339 | { | ||
340 | FILE *f; | ||
341 | |||
342 | if (( f = ::fopen ( pidfile_path, "w" ))) { | ||
343 | ::fprintf ( f, "%d", getpid ( )); | ||
344 | ::fclose ( f ); | ||
345 | } | ||
346 | } | ||
347 | |||
348 | void remove_pidfile ( ) | ||
349 | { | ||
350 | ::unlink ( pidfile_path ); | ||
351 | } | ||
352 | |||
353 | void handle_sigterm ( int sig ) | ||
354 | { | ||
355 | if ( qApp ) | ||
356 | qApp-> quit ( ); | ||
357 | } | ||
358 | |||
336 | int main( int argc, char ** argv ) | 359 | int main( int argc, char ** argv ) |
337 | { | 360 | { |
338 | #ifndef SINGLE_APP | 361 | #ifndef SINGLE_APP |
339 | signal( SIGCHLD, SIG_IGN ); | 362 | ::signal( SIGCHLD, SIG_IGN ); |
363 | |||
364 | ::signal ( SIGTERM, handle_sigterm ); | ||
365 | |||
366 | ::setsid ( ); | ||
367 | ::setpgid ( 0, 0 ); | ||
368 | |||
369 | ::atexit ( remove_pidfile ); | ||
370 | create_pidfile ( ); | ||
340 | #endif | 371 | #endif |
341 | 372 | ||
342 | int retVal = initApplication( argc, argv ); | 373 | int retVal = initApplication ( argc, argv ); |
343 | 374 | ||
344 | #ifndef SINGLE_APP | 375 | #ifndef SINGLE_APP |
345 | // Kill them. Kill them all. | 376 | // Kill them. Kill them all. |
346 | setpgid( getpid(), getppid() ); | 377 | ::kill ( 0, SIGTERM ); |
347 | killpg( getpid(), SIGTERM ); | 378 | ::sleep( 1 ); |
348 | sleep( 1 ); | 379 | ::kill ( 0, SIGKILL ); |
349 | killpg( getpid(), SIGKILL ); | ||
350 | #endif | 380 | #endif |
351 | 381 | ||
352 | return retVal; | 382 | return retVal; |