From owner-freebsd-questions Fri Nov 7 18:47:21 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id SAA11516 for questions-outgoing; Fri, 7 Nov 1997 18:47:21 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from zeus.carroll.com (zeus.carroll.com [199.224.10.2]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id SAA11511 for ; Fri, 7 Nov 1997 18:47:15 -0800 (PST) (envelope-from jim@carroll.com) Received: from apollo.carroll.com [199.224.10.3] by zeus.carroll.com with ESMTP (8.8.5/0) id VAA03729; Fri, 7 Nov 1997 21:47:14 -0500 Received: by apollo.carroll.com (8.8.5) is VAA20546; Fri, 7 Nov 1997 21:47:13 -0500 Date: Fri, 7 Nov 1997 21:47:08 -0500 From: Jim Carroll To: freebsd-questions@freebsd.org Subject: wait not interrupted on signal Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk I have a piece of code that depends on being notified when a child process sends it a signal. The parent spends most of it's life waiting for this signal. The mechanism I have tried to use is to trap SIGUSR1 in the parent, then execute a wait() system call. From my reading of the wait(2) man pages and the sigaction(2) pages, the wait call in the parent should be interrupted when the child task posts SIGUSR1. I'm not sure what I'm doing wrong, but I cannot get the wait() call to interrupt. I had print routines that seem to indicate that the signal was caught, but the wait refuses to return to the parent until the child dies. I have narrowed the problem down to the smallest piece of code I could develope, and included it below. In the example below, I would expect to see: wait for child SIGUSR1 caught errno: 4 The last line indicates that an errno 4 (EINTR) was received. Instead, we are seeing: wait for child SIGUSR1 caught errno: 0 We are running FreeBSD 2.2.1 Any assistance would be appreciated. Thanks in advance =-=-=-=-= SAMPLE CODE -=-=-=-=-=-=-= #include #include #include #include #include #include #include void sigreset(int s) { fprintf(stderr,"SIGUSR1 caught\n"); } void main(int argc, char* argv[]) { int p, s; signal(SIGUSR1, sigreset); /* prepare to catch signal */ if ((p = fork()) == 0) { /* in child */ sleep(2); kill(getppid(), SIGUSR1); /* post signal to parent */ sleep(5); return; } /* in parent */ fprintf(stderr, "wait for child\n"); wait(&s); /* wait for EINTR or child dealth */ fprintf(stderr, "errno: %d\n", errno); } --- Jim C., President | C A R R O L L - N E T, Inc. 201-488-1332 | New Jersey's Premier Internet Service Provider www.carroll.com |