77
|
1 /* Program to produce output at regular intervals. */
|
|
2
|
15104
|
3 #ifdef HAVE_CONFIG_H
|
4696
|
4 #include <config.h>
|
15104
|
5 #endif
|
4127
|
6
|
77
|
7 #include <stdio.h>
|
4127
|
8 #include <sys/types.h>
|
|
9
|
|
10 #ifdef TIME_WITH_SYS_TIME
|
|
11 #include <sys/time.h>
|
77
|
12 #include <time.h>
|
4127
|
13 #else
|
|
14 #ifdef HAVE_SYS_TIME_H
|
3437
|
15 #include <sys/time.h>
|
4127
|
16 #else
|
|
17 #include <time.h>
|
|
18 #endif
|
|
19 #endif
|
77
|
20
|
|
21 struct tm *localtime ();
|
|
22
|
9491
|
23 void
|
77
|
24 main (argc, argv)
|
|
25 int argc;
|
|
26 char **argv;
|
|
27 {
|
|
28 int period = 60;
|
3336
|
29 time_t when;
|
77
|
30 struct tm *tp;
|
|
31
|
|
32 if (argc > 1)
|
|
33 period = atoi (argv[1]);
|
|
34
|
|
35 while (1)
|
|
36 {
|
366
|
37 /* Make sure wakeup stops when Emacs goes away. */
|
|
38 if (getppid () == 1)
|
|
39 exit (0);
|
77
|
40 printf ("Wake up!\n");
|
|
41 fflush (stdout);
|
|
42 /* If using a period of 60, produce the output when the minute
|
|
43 changes. */
|
|
44 if (period == 60)
|
|
45 {
|
|
46 time (&when);
|
|
47 tp = localtime (&when);
|
|
48 sleep (60 - tp->tm_sec);
|
|
49 }
|
|
50 else
|
|
51 sleep (period);
|
|
52 }
|
|
53 }
|