From owner-freebsd-bugs Thu Apr 20 05:53:04 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id FAA27274 for bugs-outgoing; Thu, 20 Apr 1995 05:53:04 -0700 Received: from mail.barrnet.net (mail.BARRNET.NET [131.119.246.7]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id FAA27268 for ; Thu, 20 Apr 1995 05:52:57 -0700 Received: from gwdu17.gwdg.de (gwdu17.gwdg.de [134.76.10.98]) by mail.barrnet.net (8.6.10/MAIL-RELAY-LEN) with SMTP id FAA21211 for ; Thu, 20 Apr 1995 05:49:55 -0700 Received: from namu01.gwdg.de (actually namu07.gwdg.de) by gwdu17.gwdg.de with SMTP (PP); Thu, 20 Apr 1995 14:57:04 +0200 Received: by namu01.gwdg.de (5.57/Ultrix3.0-C) id AA26059; Thu, 20 Apr 95 14:50:45 +0200 Date: Thu, 20 Apr 95 14:50:45 +0200 From: rw@namu01.gwdg.de (Rainer Wittmann UMS) Message-Id: <9504201250.AA26059@namu01.gwdg.de> To: bugs@FreeBSD.org Subject: signal handling bug Sender: bugs-owner@FreeBSD.org Precedence: bulk Any unix system, I know, except FreeBSD 2.0, behaves as follows, if a process is reading from a slow device like standard input from a terminal. If this process receives a signal, for which a signal handler was installed by the process, then immediately control is tranferred to the signal handler (FreeBSD does this as well). After the signal was serviced, the read system call is termianted and errno is set to EINTR. Rather then doing this, FreeBSD completes the read system call, as if no signal would have arrived. This misbehavior breaks some of may programs. No matter, how often it gets a signal. It NEVER sets errno to EINTR. This behavior also contradicts the man page of read. To verify the above, run the program below and press `ctrl-c' or send SIGINT to it. On FreeBSD it doesn't immediately terminate as it does on any other unix. #include #include #include #include void SIGINT_handler(void) { signal(SIGINT, (void (*)(int))SIGINT_handler); fprintf(stdout, "\nSIGINT received\n"); } char chr; void main(void) { signal(SIGINT, (void (*)(int))SIGINT_handler); errno = 0; read(0, &chr, 1); if( errno == EINTR ) fprintf(stdout, "errno = EINTR\n"); }