Mercurial > emacs
annotate lib-src/=wakeup.c @ 3699:7be0f0a02725
Updated GPL version to 2.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 12 Jun 1993 22:01:38 +0000 |
parents | 0810187da5d9 |
children | d253c8a4b7e5 |
rev | line source |
---|---|
77 | 1 /* Program to produce output at regular intervals. */ |
2 | |
3 #include <stdio.h> | |
4 #include <time.h> | |
3572
0810187da5d9
* wakeup.c: Include sys/types.h, too; I think that's where time_t
Jim Blandy <jimb@redhat.com>
parents:
3437
diff
changeset
|
5 #include <sys/types.h> |
3437 | 6 #include <sys/time.h> |
77 | 7 |
8 struct tm *localtime (); | |
9 | |
10 main (argc, argv) | |
11 int argc; | |
12 char **argv; | |
13 { | |
14 int period = 60; | |
3336
44df7395bed8
(main): Make when a time_t.
Richard M. Stallman <rms@gnu.org>
parents:
366
diff
changeset
|
15 time_t when; |
77 | 16 struct tm *tp; |
17 | |
18 if (argc > 1) | |
19 period = atoi (argv[1]); | |
20 | |
21 while (1) | |
22 { | |
366 | 23 /* Make sure wakeup stops when Emacs goes away. */ |
24 if (getppid () == 1) | |
25 exit (0); | |
77 | 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 } |