mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
Initial revision
This commit is contained in:
parent
d5aa8b0229
commit
58fd8a8184
1 changed files with 34 additions and 0 deletions
34
lib-src/wakeup.c
Normal file
34
lib-src/wakeup.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* Program to produce output at regular intervals. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
struct tm *localtime ();
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int period = 60;
|
||||
long when;
|
||||
struct tm *tp;
|
||||
|
||||
if (argc > 1)
|
||||
period = atoi (argv[1]);
|
||||
|
||||
while (1)
|
||||
{
|
||||
printf ("Wake up!\n");
|
||||
fflush (stdout);
|
||||
/* If using a period of 60, produce the output when the minute
|
||||
changes. */
|
||||
if (period == 60)
|
||||
{
|
||||
time (&when);
|
||||
tp = localtime (&when);
|
||||
sleep (60 - tp->tm_sec);
|
||||
}
|
||||
else
|
||||
sleep (period);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue