Path: csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail From: Stephane Chazelas Newsgroups: gnu.bash.bug Subject: Re: SIGINT handling Date: Mon, 21 Sep 2015 10:48:07 +0100 Lines: 49 Approved: bug-bash@gnu.org Message-ID: References: <20150918151439.GA16455@chaz.gmail.com> <20150919203628.GA27872@chaz.gmail.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1442828899 12584 208.118.235.17 (21 Sep 2015 09:48:19 GMT) X-Complaints-To: action@cs.stanford.edu Cc: Jilles Tjoelker To: bug-bash Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=wJJWVvj2bMtIbsEdllh1gu/NH8b//iHY8yfPsGKdO8k=; b=lj6+rYhhSYf8S5NXS/82x//SUnmqyNq/8yOECUqb9I9HrAks4dWBcgaZqgcM6eCmxJ +K4Ml39C/qDXpAc3ruyjspsLzjzOkMDP9pJl+D32i+lGqbO2RPT5sFjhndKHyVu0dPTP KdHGiu3mZxC+dHhLL1aRu8Vr8zr6nRsv0tvOy2mWvixAxmj33AzzRmG9EM0PmHxL6oe5 /TUICXK8pW4x/qBa/iM9jDZBvV0y7DwS9wbXz3wKiVX7HJumRJz2WFMYVQfEyq8WnKP3 03RRGTawzEp3O48f2a4xnmWdap80VDjBVHJque6sp38mi2mKWaV7xFoRa/H+NLkVe9Lu Cotg== X-Received: by 10.180.104.68 with SMTP id gc4mr12688871wib.78.1442828888718; Mon, 21 Sep 2015 02:48:08 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20150919203628.GA27872@chaz.gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22a X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11520 2015-09-19 21:36:28 +0100, Stephane Chazelas: > 2015-09-18 16:14:39 +0100, Stephane Chazelas: > [...] > > In: > > > > bash -c 'sh -c "trap exit INT; sleep 10; :"; echo hi' > > > > If I press Ctrl-C, I still see "hi". > [...] > > Jilles provided with the explanation at > http://unix.stackexchange.com/a/230731 > > with a link to: > http://www.cons.org/cracauer/sigint.html [...] Note that bash (and ksh, contrary to FreeBSD sh) is not consistent in its handling of that "WCE" (for "wait and cooperative exit") approach in that pressing ^C in: bash -c ' var=$(sh -c "trap \"\" INT; sleep 3; echo result) echo "$var" ' kills bash, leaving the "sh" and "sleep" running unattended in background. Same for: bash -O lastpipe -c ' sh -c "trap \"\" INT; sleep 3; echo test" | read var; echo done' One could also argue, that to be consistent, SIGTSTP and SIGQUIT should be treated similarly (strangely enough http://www.cons.org/cracauer/sigint.html doesn't mention SIGTSTP). I'm not sure I prefer that WCE approach over WUE. Wouldn't it be preferable that applications that intercept SIGINT/QUIT/TSTP for anything other than clean-up before exit/suspend implement job control themselves instead (like vi's :! should create a process group and make that the foreground process group of the terminal so pressing ^C in sh -c vi, :!sleep 10, only sends the SIGINT to sleep)? -- Stephane