changeset 2102:b11495a4ecdf

* timer.c (main): Set the ownership of the stdin file descriptor to the current process. Print error messages if either of the fcntl's fails. * timer.c (sigcatch): Declare this to return SIGTYPE (defined in ../src/config.h), not void.
author Jim Blandy <jimb@redhat.com>
date Thu, 11 Mar 1993 07:00:12 +0000
parents df8249aa4901
children bd76e0e3622c
files lib-src/=timer.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/=timer.c	Thu Mar 11 06:59:53 1993 +0000
+++ b/lib-src/=timer.c	Thu Mar 11 07:00:12 1993 +0000
@@ -213,7 +213,7 @@
   notify ();
 }
 
-void
+SIGTYPE
 sigcatch (sig)
      int sig;
 /* dispatch on incoming signal, then restore it */
@@ -262,7 +262,18 @@
   signal (SIGTERM, sigcatch);
 
 #ifndef USG
-  fcntl (0, F_SETFL, FASYNC);
+  if (fcntl (0, F_SETOWN, getpid ()) == -1)
+    {
+      fprintf (stderr, "%s: can't set ownership of stdin\n", pname);
+      fprintf (stderr, "%s\n", sys_errlist[errno]);
+      exit (1);
+    }
+  if (fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) | FASYNC) == -1)
+    {
+      fprintf (stderr, "%s: can't request asynchronous I/O on stdin\n", pname);
+      fprintf (stderr, "%s\n", sys_errlist[errno]);
+      exit (1);
+    }
 #endif /* USG */
 
   while (1) pause ();