summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/opiealarm/opiealarm.c2
1 files changed, 2 insertions, 0 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
@@ -249,24 +249,25 @@ int suspend ( int fix_rtc )
249 if ( ioctl ( fd, RTC_SET_TIME, &set ) < 0 ) 249 if ( ioctl ( fd, RTC_SET_TIME, &set ) < 0 )
250 break; // ( 1, "ioctl RTC_SET_TIME" ); 250 break; // ( 1, "ioctl RTC_SET_TIME" );
251 } 251 }
252 252
253 // read the wakeup time from TIMEFILE 253 // read the wakeup time from TIMEFILE
254 if (!( fp = fopen ( TIMEFILE, "r" ))) 254 if (!( fp = fopen ( TIMEFILE, "r" )))
255 break; // ( 1, TIMEFILE ); 255 break; // ( 1, TIMEFILE );
256 256
257 if ( !fgets ( buf, sizeof( buf ) - 1, fp )) 257 if ( !fgets ( buf, sizeof( buf ) - 1, fp ))
258 break; // ( 1, TIMEFILE ); 258 break; // ( 1, TIMEFILE );
259 259
260 fclose ( fp ); 260 fclose ( fp );
261 fp = 0;
261 262
262 alrt = atoi ( buf ); // get the alarm time 263 alrt = atoi ( buf ); // get the alarm time
263 264
264 if ( alrt == 0 ) 265 if ( alrt == 0 )
265 break; // ( 0, TIMEFILE " contains an invalid time description" ); 266 break; // ( 0, TIMEFILE " contains an invalid time description" );
266 alrt -= 5; // wake up 5 sec before the specified time 267 alrt -= 5; // wake up 5 sec before the specified time
267 268
268 alr = *gmtime ( &alrt ); 269 alr = *gmtime ( &alrt );
269 270
270 if ( ioctl ( fd, RTC_ALM_SET, &alr ) < 0 ) // set RTC alarm time 271 if ( ioctl ( fd, RTC_ALM_SET, &alr ) < 0 ) // set RTC alarm time
271 break; // ( 1, "ioctl RTC_ALM_SET" ); 272 break; // ( 1, "ioctl RTC_ALM_SET" );
272 273
@@ -277,24 +278,25 @@ int suspend ( int fix_rtc )
277 kill ( parent_pid, SIGUSR1 ); 278 kill ( parent_pid, SIGUSR1 );
278 279
279 if ( read ( fd, buf, sizeof( unsigned long )) < 0 ) // wait for the RTC alarm irq 280 if ( read ( fd, buf, sizeof( unsigned long )) < 0 ) // wait for the RTC alarm irq
280 break; // ( 1, "read rtc alarm" ); 281 break; // ( 1, "read rtc alarm" );
281 282
282 // iPAQ woke up via RTC irq -- otherwise we would have received a SIGUSR2 283 // iPAQ woke up via RTC irq -- otherwise we would have received a SIGUSR2
283 // from the "resume instance" of opiealarm. 284 // from the "resume instance" of opiealarm.
284 285
285 if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 ) // disable RTC alarm irq 286 if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 ) // disable RTC alarm irq
286 break; // ( 1, "ioctl RTC_AIE_OFF" ); 287 break; // ( 1, "ioctl RTC_AIE_OFF" );
287 288
288 close ( fd ); 289 close ( fd );
290 fd = -1;
289 291
290 remove_pidfile ( ); 292 remove_pidfile ( );
291 293
292 return 0; 294 return 0;
293 295
294 } while ( 0 ); 296 } while ( 0 );
295 297
296 if ( fp != NULL ) 298 if ( fp != NULL )
297 fclose ( fp ); 299 fclose ( fp );
298 300
299 if ( fd != -1 ) 301 if ( fd != -1 )
300 close ( fd ); 302 close ( fd );