From owner-freebsd-questions@FreeBSD.ORG Sun Jan 22 13:27:54 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2A29D16A41F for ; Sun, 22 Jan 2006 13:27:54 +0000 (GMT) (envelope-from bagoap@xs4all.nl) Received: from smtp-vbr16.xs4all.nl (smtp-vbr16.xs4all.nl [194.109.24.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1391043D53 for ; Sun, 22 Jan 2006 13:27:52 +0000 (GMT) (envelope-from bagoap@xs4all.nl) Received: from huiskamer.xs4all.nl (thuiswater.xs4all.nl [80.127.16.130]) (authenticated bits=0) by smtp-vbr16.xs4all.nl (8.13.3/8.13.3) with ESMTP id k0MDRnHi063573 for ; Sun, 22 Jan 2006 14:27:50 +0100 (CET) (envelope-from bagoap@xs4all.nl) Message-Id: <7.0.1.0.2.20060122134143.02183648@thuiswater.nl> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Sun, 22 Jan 2006 14:27:41 +0100 To: freebsd-questions@freebsd.org From: Peter Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by XS4ALL Virus Scanner Subject: wait(2) does not return after SIGCONT X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jan 2006 13:27:54 -0000 Hello, I call waitpid() with the WUNTRACED|WCONTINUED options set in order to know when the child process receives SIGSTOP's and SIGCONT's. The SIGSTOP is not the problem, but I can't get the SIGCONTs to work. The appended code illustrates the problem: SIGCONTs to the child do continue the child process but waitpid() remains blocked and the SIGCONT is just not noticed by the parent. The code is however fully functional under Sparc Solaris 2 (can't remember the exact version). Under FreeBSD it only works when the SIGCONT is sent directly from the parent (see the line in the example code that is commented-out). But this is not what I want. What am I missing? Thanks! (problem seen with FreeBSD 5.3, 5.4 and 6.0, i386 and adm64) #include #include #include #include main() { pid_t pid; if ( (pid = fork()) == -1 ) printf("could not fork"); else if ( pid == 0 ) { /* child */ sleep(1); /* wait for the parent to prepair */ kill(getpid(),SIGSTOP); /* send SIGSTOP to myself */ while(1); /* loop */ } else { /* parent */ int stat; waitpid(pid,&stat,WUNTRACED|WCONTINUED); while ( WIFSTOPPED(stat) || WIFCONTINUED(stat) ) { if ( WIFSTOPPED(stat) ) { printf("child was stopped\n"); /* if the next line is uncommented, SIGCONT is caught property */ /* kill(pid,SIGCONT); */ } if ( WIFCONTINUED(stat) ) { /* this part is never reached */ printf("child was continued\n"); kill(pid,SIGTERM); /* terminate child */ } waitpid(pid,&stat,WUNTRACED|WCONTINUED); } } }