(mouse-save-then-kill): Fix paren error in last change.
[emacs.git] / lib-src / wakeup.c
blobe481bee8324fd6d57237403927b1f7f3f5a062a3
1 /* Program to produce output at regular intervals. */
3 #include "config.h"
5 #include <stdio.h>
6 #include <sys/types.h>
8 #ifdef TIME_WITH_SYS_TIME
9 #include <sys/time.h>
10 #include <time.h>
11 #else
12 #ifdef HAVE_SYS_TIME_H
13 #include <sys/time.h>
14 #else
15 #include <time.h>
16 #endif
17 #endif
19 struct tm *localtime ();
21 main (argc, argv)
22 int argc;
23 char **argv;
25 int period = 60;
26 time_t when;
27 struct tm *tp;
29 if (argc > 1)
30 period = atoi (argv[1]);
32 while (1)
34 /* Make sure wakeup stops when Emacs goes away. */
35 if (getppid () == 1)
36 exit (0);
37 printf ("Wake up!\n");
38 fflush (stdout);
39 /* If using a period of 60, produce the output when the minute
40 changes. */
41 if (period == 60)
43 time (&when);
44 tp = localtime (&when);
45 sleep (60 - tp->tm_sec);
47 else
48 sleep (period);