Subject: bin/3713: crontab should catch/ignore some signals
To: None <gnats-bugs@gnats.netbsd.org>
From: Andrew Brown <codewarrior@daemon.org>
List: netbsd-bugs
Date: 06/06/1997 00:20:07
>Number:         3713
>Category:       bin
>Synopsis:       crontab fails miserably when signals happen
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun  5 21:35:01 1997
>Last-Modified:
>Originator:     Andrew Brown
>Organization:
none
>Release:        1.2 (but current is no different)
>Environment:
System: NetBSD noc 1.2 NetBSD 1.2 (null) #1: Sun Feb 16 15:43:11 PST 1997 root@noc:/usr/src/sys/arch/i386/compile/null i386
i'm using tcsh, but the shell probably doesn't make a difference
(except perhaps the bourne shell)

>Description:

     crontab dies when signals are generated from the keyboard (^C
   affects ed, probably vi as well, amd ^G works quite well in emacs)
   even if the editor doesn't.  this can either leave you with an
   orphaned editor process (emacs) or an editor panicking madly about not
   being able to read stdin correctly.  i've looked at the current source
   (vs. my 1.2 source) and the only changes i can see are towards
   security (strncpy vs. strcpy...that sort of thing).  i'm led to
   believe that send-pr suffers the same problem, so i'm trying not to
   hit ^G right now...  :)

>How-To-Repeat:

   andrew@noc::ttyp2:~> setenv VISUAL ed
   andrew@noc::ttyp2:~> crontab -e
   263
   ^C
   ?

   andrew@noc::ttyp2:~> (hit space a few times)
   stdin: Input/output error
   stdin: Input/output error
   stdin: Input/output error
   (repeats until you kill ed from another terminal)

>Fix:

*** crontab.c.orig	Tue Mar 29 20:46:45 1994
--- crontab.c	Fri Jun  6 00:13:22 1997
***************
*** 42,47 ****
--- 42,48 ----
  #if defined(POSIX)
  # include <locale.h>
  #endif
+ #include <sys/signal.h>
  
  
  #define NHEADER_LINES 3
***************
*** 94,99 ****
--- 95,103 ----
  
  	Pid = getpid();
  	ProgramName = argv[0];
+ 
+ 	signal(SIGINT,SIG_IGN);
+ 	signal(SIGABRT,SIG_IGN);
  
  #if defined(POSIX)
  	setlocale(LC_ALL, "");
>Audit-Trail:
>Unformatted: