view lib-src/=wakeup.c @ 2116:76df2de3dd55

* s/usg5-4.h: Changes from Eric Raymond: If we're doing ordinary linking, define LIB_STANDARD appropriately. Give LIBS_DEBUG a null definition; usg5-4 has no -lg. #define LIBS_STANDARD as "-lc"; usg5-4 has no -lPW. #define NSIG, if it's not already defined. #define HAVE_TERMIOS instead of HAVE_TCATTR. Provide our own definition of LIB_X11_LIB.
author Jim Blandy <jimb@redhat.com>
date Thu, 11 Mar 1993 07:11:06 +0000
parents f756ede77561
children 44df7395bed8
line wrap: on
line source

/* 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)
    {
      /* Make sure wakeup stops when Emacs goes away.  */
      if (getppid () == 1)
	exit (0);
      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);
    }
}