Mercurial > hg > xemacs-beta
comparison lib-src/wakeup.c @ 169:15872534500d r20-3b11
Import from CVS: tag r20-3b11
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:46:53 +0200 |
parents | ac2d302a0011 |
children | e11d67e05968 |
comparison
equal
deleted
inserted
replaced
168:9851d5c6556e | 169:15872534500d |
---|---|
19 #else | 19 #else |
20 #include <time.h> | 20 #include <time.h> |
21 #endif | 21 #endif |
22 #endif | 22 #endif |
23 | 23 |
24 void | 24 int |
25 main (argc, argv) | 25 main (int argc, char *argv[]) |
26 int argc; | |
27 char **argv; | |
28 { | 26 { |
29 int period = 60; | 27 int period = 60; |
30 time_t when; | |
31 struct tm *tp; | |
32 | 28 |
33 if (argc > 1) | 29 if (argc > 1) |
34 period = atoi (argv[1]); | 30 period = atoi (argv[1]); |
35 | 31 |
36 while (1) | 32 while (1) |
37 { | 33 { |
38 /* Make sure wakeup stops when Emacs goes away. */ | 34 /* Make sure wakeup stops when Emacs goes away. */ |
39 if (getppid () == 1) | 35 if (getppid () == 1) |
40 exit (0); | 36 return 0; |
41 printf ("Wake up!\n"); | 37 printf ("Wake up!\n"); |
42 fflush (stdout); | 38 fflush (stdout); |
43 /* If using a period of 60, produce the output when the minute | 39 /* If using a period of 60, produce the output when the minute |
44 changes. */ | 40 changes. */ |
45 if (period == 60) | 41 if (period == 60) |
46 { | 42 { |
43 time_t when; | |
44 struct tm *tp; | |
47 time (&when); | 45 time (&when); |
48 tp = localtime (&when); | 46 tp = localtime (&when); |
49 sleep (60 - tp->tm_sec); | 47 sleep (60 - tp->tm_sec); |
50 } | 48 } |
51 else | 49 else |