summaryrefslogtreecommitdiff
path: root/core/opiealarm
Unidiff
Diffstat (limited to 'core/opiealarm') (more/less context) (show whitespace changes)
-rw-r--r--core/opiealarm/opiealarm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c
index 90a743f..422865c 100644
--- a/core/opiealarm/opiealarm.c
+++ b/core/opiealarm/opiealarm.c
@@ -327,58 +327,58 @@ int onac ( void )
327 return on; 327 return on;
328} 328}
329 329
330int resume ( int resuspend ) 330int resume ( int resuspend )
331{ 331{
332 FILE *fp; 332 FILE *fp;
333 333
334 // re-suspend when on AC (optional) when woken up via RTC 334 // re-suspend when on AC (optional) when woken up via RTC
335 335
336 if ( !opiealarm_was_running ) { 336 if ( !opiealarm_was_running ) {
337 // if opiealarm -s didn't wake up via RTC, the old process gets killed 337 // if opiealarm -s didn't wake up via RTC, the old process gets killed
338 // by kill_by_pidfile(), which is recorded in opiealarm_was_running 338 // by kill_by_pidfile(), which is recorded in opiealarm_was_running
339 339
340 if ( resuspend && onac ( )) { 340 if ( resuspend && onac ( )) {
341 time_t start, now; 341 time_t start, now;
342 char *argv [4]; 342 char *argv [4];
343 343
344 if ( !fork_with_pidfile ( )) 344 if ( !fork_with_pidfile ( ))
345 return 4; 345 return 4;
346 346
347 // we can't wait for the resuspend timeout in the parent process. 347 // we can't wait for the resuspend timeout in the parent process.
348 // so we fork and tell the parent it can exit immediatly 348 // so we fork and tell the parent it can exit immediatly
349 349
350 kill ( parent_pid, SIGUSR1 ); 350 kill ( parent_pid, SIGUSR1 );
351 351
352 // sleep <resuspend> seconds - this method is much more precise than sleep() ! 352 // sleep <resuspend> seconds - this method is much more precise than sleep() !
353 time ( &start ); 353 time ( &start );
354 do { 354 do {
355 sleep ( 1 ); 355 sleep ( 1 );
356 time ( &now ); 356 time ( &now );
357 } while (( now - start ) < resuspend ); 357 } while (( now - start ) < resuspend );
358 358
359 if ( onac ( )) { // still on ac ? 359 if ( onac ( )) { // still on ac ?
360 argv[0] = "qcop"; 360 argv[0] = "qcop";
361 argv[1] = "QPE/Desktop"; 361 argv[1] = "QPE/Desktop";
362 argv[2] = "suspend()"; 362 argv[2] = "suspend()";
363 argv[3] = 0; 363 argv[3] = 0;
364 364
365 // hard coded for now ...but needed 365 // hard coded for now ...but needed
366 // another way would be to simulate a power-button press 366 // another way would be to simulate a power-button press
367 367
368 setenv ( "LOGNAME", "root", 1 ); 368 setenv ( "LOGNAME", "root", 1 );
369 setenv ( "HOME", "/root", 1 ); 369 setenv ( "HOME", "/root", 1 );
370 setenv ( "LD_LIBRARY_PATH", "/opt/QtPalmtop/lib", 1 ); 370 setenv ( "LD_LIBRARY_PATH", "/opt/QtPalmtop/lib", 1 );
371 setenv ( "QTDIR", "/opt/QtPalmtop", 1 ); 371 setenv ( "QTDIR", "/opt/QtPalmtop", 1 );
372 372
373 remove_pidfile ( ); 373 remove_pidfile ( );
374 374
375 // no need for system() since this process is no longer usefull anyway 375 // no need for system() since this process is no longer useful anyway
376 execv ( "/opt/QtPalmtop/bin/qcop", argv ); 376 execv ( "/opt/QtPalmtop/bin/qcop", argv );
377 377
378 perror ( "exec for qcop failed" ); 378 perror ( "exec for qcop failed" );
379 return 5; 379 return 5;
380 } 380 }
381 } 381 }
382 } 382 }
383 return 0; 383 return 0;
384} 384}