view lib-src/=wakeup.c @ 5494:1ea2b4351945

[MSDOS]: #include "msdos.h" and <sys/param.h> needed for the following changes. (Ffile_name_directory, Fexpand_file_name) [FILE_SYSTEM_CASE]: Apply case conversion if defined. (Ffile_name_directory, Ffile_name_nondirectory, file_name_as_directory, directory_file_name, Fexpand_file_name, Fsubstitute_in_file_name, expand_and_dir_to_file) [MSDOS]: Drive letter support. (Fexpand_file_name) [MSDOS]: Support for multiple default directories. (Ffile_writeable_p) [MSDOS]: Don't call access with file name ending in slash. (Finsert_file_contents) [MSDOS]: Determine file type by name (call find-buffer-file-type) and change CR+LF to LF if it is a text file. (Fwrite_region) [MSDOS]: Use text/binary mode as specified by buffer_file_type. (syms_of_fileio) [MSDOS]: Set Qfind_buffer_file_type. (Fsubstitute_in_file_name) [MSDOS]: Ignore case in environtment variable.
author Richard M. Stallman <rms@gnu.org>
date Sat, 08 Jan 1994 09:15:49 +0000
parents 1fc792473491
children dd3b83e4ceb0
line wrap: on
line source

/* Program to produce output at regular intervals.  */

#include <config.h>

#include <stdio.h>
#include <sys/types.h>

#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif

struct tm *localtime ();

main (argc, argv)
     int argc;
     char **argv;
{
  int period = 60;
  time_t 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);
    }
}