summaryrefslogtreecommitdiff
authorzecke <zecke>2003-06-13 10:41:14 (UTC)
committer zecke <zecke>2003-06-13 10:41:14 (UTC)
commit60ba51b33a060dde352caa678f2e337f5f5590f5 (patch) (side-by-side diff)
tree29da8884e438bb768f2d0a5f41dbaad62ce7776c
parent3dd3e5caf9ca85c814442b04485f07da060dc257 (diff)
downloadopie-60ba51b33a060dde352caa678f2e337f5f5590f5.zip
opie-60ba51b33a060dde352caa678f2e337f5f5590f5.tar.gz
opie-60ba51b33a060dde352caa678f2e337f5f5590f5.tar.bz2
fix here as well
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opiealarm/opiealarm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c
index 072dca7..465e633 100644
--- a/core/opiealarm/opiealarm.c
+++ b/core/opiealarm/opiealarm.c
@@ -83,25 +83,25 @@ int fork_with_pidfile ( void )
// the iPAQ just before the child process sets the RTC.
// Solution: just wait for SIGUSR1 - the child process will
// signal this when it thinks it is safe to exit.
signal ( SIGUSR1, sig_handler_parent );
while ( 1 )
sleep ( 1000 );
exit ( 0 );
}
else if ( pid < 0 ) {
perror ( "forking failed" );
return 0;
- }
+ }
// child process needs to react to SIGUSR2. This is sent when
// a new opiealarm process is started.
signal ( SIGUSR2, sig_handler_child );
// save pid
if (( fp = fopen ( PIDFILE, "w" ))) {
fprintf ( fp, "%d", getpid ( ));
fclose ( fp );
// detach
@@ -249,24 +249,25 @@ int suspend ( int fix_rtc )
if ( ioctl ( fd, RTC_SET_TIME, &set ) < 0 )
break; // ( 1, "ioctl RTC_SET_TIME" );
}
// read the wakeup time from TIMEFILE
if (!( fp = fopen ( TIMEFILE, "r" )))
break; // ( 1, TIMEFILE );
if ( !fgets ( buf, sizeof( buf ) - 1, fp ))
break; // ( 1, TIMEFILE );
fclose ( fp );
+ fp = 0;
alrt = atoi ( buf ); // get the alarm time
if ( alrt == 0 )
break; // ( 0, TIMEFILE " contains an invalid time description" );
alrt -= 5; // wake up 5 sec before the specified time
alr = *gmtime ( &alrt );
if ( ioctl ( fd, RTC_ALM_SET, &alr ) < 0 ) // set RTC alarm time
break; // ( 1, "ioctl RTC_ALM_SET" );
@@ -277,24 +278,25 @@ int suspend ( int fix_rtc )
kill ( parent_pid, SIGUSR1 );
if ( read ( fd, buf, sizeof( unsigned long )) < 0 ) // wait for the RTC alarm irq
break; // ( 1, "read rtc alarm" );
// iPAQ woke up via RTC irq -- otherwise we would have received a SIGUSR2
// from the "resume instance" of opiealarm.
if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 ) // disable RTC alarm irq
break; // ( 1, "ioctl RTC_AIE_OFF" );
close ( fd );
+ fd = -1;
remove_pidfile ( );
return 0;
} while ( 0 );
if ( fp != NULL )
fclose ( fp );
if ( fd != -1 )
close ( fd );