Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: gentoo_eshoes@tutanota.com Newsgroups: gnu.bash.bug Subject: Re: looking for consistent C-c trap behavior Date: Fri, 17 Apr 2020 22:18:29 +0200 (CEST) Lines: 34 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1587154715 15614 209.51.188.17 (17 Apr 2020 20:18:35 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: Eduardo Bustamante Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1587154709; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=O1fLPowcT4e8VwE3UZkfUDDvH+rRZcyNtHlmJk9Jitc=; b=pJcPBhh4LzM3w+iuaK93/WKqXACkcjspgt8nDJpn6DwPYsr3iobtnVowI8CfSbK7 mIC+oYyWM8lt3zCEJYL1FfDXnjsdK6AJrHv5V89cfIYvueUzbSPMzVlCV8YjEIUMUBs OdKIbGmYfeGhlVYOjyPWlVf5OLepMYMdMiJqZBvvEQ1n35+q08sjIUOY2dbiB3Bg7FX p/sETKP8blS0TSMlsQqw5/bAxyxo0YMyA+meg8U+J3uuSeIjz2iMPZlv1czfV0hpX8q zxXfFBQ+MqpWmzbDSJE8EOwQS2wWYZsbX7Fh4yKu/tHGOotalfSq3jxSu5Lw2A7sKlw qY9NZhQvWA== In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 81.3.6.162 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com gnu.bash.bug:16158 Apr 17, 2020, 22:14 by gentoo_eshoes@tutanota.com: > > > > Apr 17, 2020, 22:02 by dualbus@gmail.com: > >> On Fri, Apr 17, 2020 at 12:59 PM gentoo_eshoes--- via Bug reports for >> the GNU Bourne Again SHell wrote: >> >>> >>> I've noticed that if I trap SIGINT in a bash script, the behavior when encountering C-c depends on whether an external command (eg. 'sleep 100') or a builtin command (like 'read -p') was encountered. >>> >>> I attach an example script which requires me to press C-c twice to interrupt the builtin 'read -p' command, and it only works because I'm restoring the trap via 'trap - SIGINT' the first time. >>> >>> My goal is to have C-c interrupt and use that exit code (130 most likely) to exit with from script, regardless or whether or not the interrupted command in the script was an internal or external one. >>> >>> How to do? >>> >> >> I recommend reading: https://www.cons.org/cracauer/sigint.html >> >> The problem is that the signal is sent to the foreground process. When >> "sleep" is running, it's the sleep command that receives the signal >> and decides what to do with it. Not bash. >> > ok but sleep is doing great - it's doing what I expect it to do and bash is trapping it just fine, it's the builtin 'read' that's the problem... > ok to be fair, you didn't really misunderstand, you were saying that if 'sleep' decided to not exit on SIGINT, there's not much I could do about it with bash/trap, or if it is... it's in that doc. Thank you for linking it.