summaryrefslogtreecommitdiff
path: root/core/opiealarm/opiealarm.c
Unidiff
Diffstat (limited to 'core/opiealarm/opiealarm.c') (more/less context) (ignore whitespace changes)
-rw-r--r--core/opiealarm/opiealarm.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c
index 998cabd..90a743f 100644
--- a/core/opiealarm/opiealarm.c
+++ b/core/opiealarm/opiealarm.c
@@ -88,16 +88,17 @@ int fork_with_pidfile ( void )
88 while ( 1 ) 88 while ( 1 )
89 sleep ( 1000 ); 89 sleep ( 1000 );
90 exit ( 0 ); 90 exit ( 0 );
91 } 91 }
92 else if ( pid < 0 ) { 92 else if ( pid < 0 ) {
93 perror ( "forking failed" ); 93 perror ( "forking failed" );
94 return 0; 94 return 0;
95 } 95 }
96 //sleep( 60 );
96 97
97 // child process needs to react to SIGUSR2. This is sent when 98 // child process needs to react to SIGUSR2. This is sent when
98 // a new opiealarm process is started. 99 // a new opiealarm process is started.
99 100
100 signal ( SIGUSR2, sig_handler_child ); 101 signal ( SIGUSR2, sig_handler_child );
101 102
102 // save pid 103 // save pid
103 if (( fp = fopen ( PIDFILE, "w" ))) { 104 if (( fp = fopen ( PIDFILE, "w" ))) {
@@ -201,17 +202,17 @@ int main ( int argc, char **argv )
201 202
202 parent_pid = 0; 203 parent_pid = 0;
203 return opt; 204 return opt;
204 } 205 }
205 206
206 207
207int suspend ( int fix_rtc ) 208int suspend ( int fix_rtc )
208{ 209{
209 FILE *fp; 210 FILE *fp = NULL;
210 char buf [64]; 211 char buf [64];
211 time_t alrt, syst, rtct; 212 time_t alrt, syst, rtct;
212 struct tm alr, sys, rtc; 213 struct tm alr, sys, rtc;
213 int fd; 214 int fd;
214 int rtc_sys_diff; 215 int rtc_sys_diff;
215 216
216 217
217 if ( !fork_with_pidfile ( )) 218 if ( !fork_with_pidfile ( ))
@@ -253,17 +254,17 @@ int suspend ( int fix_rtc )
253 // read the wakeup time from TIMEFILE 254 // read the wakeup time from TIMEFILE
254 if (!( fp = fopen ( TIMEFILE, "r" ))) 255 if (!( fp = fopen ( TIMEFILE, "r" )))
255 break; // ( 1, TIMEFILE ); 256 break; // ( 1, TIMEFILE );
256 257
257 if ( !fgets ( buf, sizeof( buf ) - 1, fp )) 258 if ( !fgets ( buf, sizeof( buf ) - 1, fp ))
258 break; // ( 1, TIMEFILE ); 259 break; // ( 1, TIMEFILE );
259 260
260 fclose ( fp ); 261 fclose ( fp );
261 fp = 0; 262 fp = NULL;
262 263
263 alrt = atoi ( buf ); // get the alarm time 264 alrt = atoi ( buf ); // get the alarm time
264 265
265 if ( alrt == 0 ) 266 if ( alrt == 0 )
266 break; // ( 0, TIMEFILE " contains an invalid time description" ); 267 break; // ( 0, TIMEFILE " contains an invalid time description" );
267 alrt -= 5; // wake up 5 sec before the specified time 268 alrt -= 5; // wake up 5 sec before the specified time
268 269
269 alr = *gmtime ( &alrt ); 270 alr = *gmtime ( &alrt );
@@ -366,17 +367,17 @@ int resume ( int resuspend )
366 367
367 setenv ( "LOGNAME", "root", 1 ); 368 setenv ( "LOGNAME", "root", 1 );
368 setenv ( "HOME", "/root", 1 ); 369 setenv ( "HOME", "/root", 1 );
369 setenv ( "LD_LIBRARY_PATH", "/opt/QtPalmtop/lib", 1 ); 370 setenv ( "LD_LIBRARY_PATH", "/opt/QtPalmtop/lib", 1 );
370 setenv ( "QTDIR", "/opt/QtPalmtop", 1 ); 371 setenv ( "QTDIR", "/opt/QtPalmtop", 1 );
371 372
372 remove_pidfile ( ); 373 remove_pidfile ( );
373 374
374 // no need for system() since this process is no longer usefull anyway 375 // no need for system() since this process is no longer usefull anyway
375 execv ( "/opt/QtPalmtop/bin/qcop", argv ); 376 execv ( "/opt/QtPalmtop/bin/qcop", argv );
376 377
377 perror ( "exec for qcop failed" ); 378 perror ( "exec for qcop failed" );
378 return 5; 379 return 5;
379 } 380 }
380 } 381 }
381 } 382 }
382 return 0; 383 return 0;