From owner-svn-src-head@FreeBSD.ORG Sun Jun 6 13:18:42 2010 Return-Path: Delivered-To: svn-src-head@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80C7D1065673; Sun, 6 Jun 2010 13:18:42 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 4347C8FC0C; Sun, 6 Jun 2010 13:18:42 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 6A5CD35A85E; Sun, 6 Jun 2010 15:18:41 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 55D15172B1; Sun, 6 Jun 2010 15:18:41 +0200 (CEST) Date: Sun, 6 Jun 2010 15:18:41 +0200 From: Jilles Tjoelker To: Andrey Chernov , Kostik Belousov , Gabor Kovesdan , src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, svn-src-head@FreeBSD.ORG Message-ID: <20100606131841.GA68034@stack.nl> References: <201006061136.o56Ba9tr029717@svn.freebsd.org> <20100606120004.GH83316@deviant.kiev.zoral.com.ua> <20100606121444.GA82819@nagual.pp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100606121444.GA82819@nagual.pp.ru> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Subject: Re: svn commit: r208868 - in head/usr.bin: bc dc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jun 2010 13:18:42 -0000 On Sun, Jun 06, 2010 at 04:14:45PM +0400, Andrey Chernov wrote: > On Sun, Jun 06, 2010 at 03:00:04PM +0300, Kostik Belousov wrote: > > On Sun, Jun 06, 2010 at 11:36:09AM +0000, Gabor Kovesdan wrote: > > > @@ -223,14 +222,11 @@ static const struct jump_entry jump_tabl > > > (sizeof(jump_table_data)/sizeof(jump_table_data[0])) > > > static void > > > -sighandler(int ignored) > > > +got_sigint(int ignored __unused) > > > { > > > > > > - switch (ignored) > > > - { > > > - default: > > > - bmachine.interrupted = true; > > > - } > > > + putchar('\n'); > > > + exit(0); > > > } > > In general, calling not async-signal safe functions from the signal > > handler is an invitation for undefined behaviour, that usually manifests > > itself as SIGSEGV and SIGBUS. > Yes, better use write(2) and _exit(2) here. I wonder if a signal handler is necessary at all here. The shell should print a newline after an interruption. This does not appear to work in sh(1) in the (default) interactive job control mode, but works in tcsh, bash and zsh for example. Additionally, an exit status of 0 is wrong because a SIGINT abort is not successful termination. It is best to resend the signal (after setting it to SIG_DFL and unmasking it) so that it looks like if the signal handler hadn't been there. Shells may rely on this to distinguish SIGINTs that caused the command to return to its main loop only and SIGINTs that aborted the entire command: in the latter case any enclosing structure should be aborted too. -- Jilles Tjoelker