* etags.c (print_help): Break up the very long strings containing
[bpt/emacs.git] / lib-src / wakeup.c
CommitLineData
58fd8a81
DM
1/* Program to produce output at regular intervals. */
2
3#include <stdio.h>
4#include <time.h>
11e5be7d 5#include <sys/types.h>
2198e8fe 6#include <sys/time.h>
58fd8a81
DM
7
8struct tm *localtime ();
9
10main (argc, argv)
11 int argc;
12 char **argv;
13{
14 int period = 60;
1da14ffd 15 time_t when;
58fd8a81
DM
16 struct tm *tp;
17
18 if (argc > 1)
19 period = atoi (argv[1]);
20
21 while (1)
22 {
7fb0d26f
JB
23 /* Make sure wakeup stops when Emacs goes away. */
24 if (getppid () == 1)
25 exit (0);
58fd8a81
DM
26 printf ("Wake up!\n");
27 fflush (stdout);
28 /* If using a period of 60, produce the output when the minute
29 changes. */
30 if (period == 60)
31 {
32 time (&when);
33 tp = localtime (&when);
34 sleep (60 - tp->tm_sec);
35 }
36 else
37 sleep (period);
38 }
39}