From owner-freebsd-arch@FreeBSD.ORG Fri Sep 7 18:19:23 2012 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71A991065673 for ; Fri, 7 Sep 2012 18:19:23 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 448738FC16 for ; Fri, 7 Sep 2012 18:19:23 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 7455CB97A; Fri, 7 Sep 2012 14:19:22 -0400 (EDT) From: John Baldwin To: Garrett Cooper Date: Fri, 7 Sep 2012 14:16:24 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p17; KDE/4.5.5; amd64; ; ) References: <201209071217.47439.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201209071416.24970.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 07 Sep 2012 14:19:22 -0400 (EDT) Cc: arch@freebsd.org Subject: Re: [PATCH] Close a race between exit1() and SIGSTOP X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2012 18:19:23 -0000 On Friday, September 07, 2012 12:35:52 pm Garrett Cooper wrote: > Does this case continue to function normally? > > $ sh -c 'while :; do sleep 1; done' > ^Z > [1]+ Stopped sh -c 'while :; do sleep 1; done' > $ kill %1 > $ fg > bash: fg: job has terminated > [1]+ Terminated: 15 sh -c 'while :; do sleep 1; done' > > $ sh -c 'while :; do sleep 1; done' > ^Z > [1]+ Stopped sh -c 'while :; do sleep 1; done' > $ kill %1 > $ kill %1 > bash: kill: (3522) - No such process > [1]+ Terminated: 15 sh -c 'while :; do sleep 1; done' > > In particular, a single kill results in the signal being sent after > the process wakes up, and a double kill results in the immediate death > of the process (in this case a shell job) (in part because of the > signals /bin/sh masks). This still works in bash: > bash $ sh -c 'while :; do sleep 1; done' ^Z [1]+ Stopped sh -c 'while :; do sleep 1; done' $ kill %1 $ fg bash: fg: job has terminated [1]+ Terminated: 15 sh -c 'while :; do sleep 1; done' $ sh -c 'while :; do sleep 1; done' ^Z [1]+ Stopped sh -c 'while :; do sleep 1; done' $ kill %1 $ kill %1 bash: kill: (61009) - No such process [1]+ Terminated: 15 sh -c 'while :; do sleep 1; done' I get different behavior in tcsh: > sh -c 'while :; do sleep 1; done' ^Z Suspended > kill %1 > [1] Terminated sh -c while :; do sleep 1; done Note that this patch merey inhibits SIGSTOP from having an effect while a process is exiting, it does not affect SIGTERM at all, so I don't think it could have any effect on this case anyway. -- John Baldwin