From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2751 invoked by alias); 4 Apr 2015 20:25:36 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20088 Received: (qmail 1989 invoked from network); 4 Apr 2015 20:25:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:in-reply-to:comments:to:subject:mime-version :content-type; bh=CZk0KQJzVx8eVkPzNTZXUZY9RsTE6pM+aoWtMNEkVeQ=; b=Y8r4szOsbZ8ZsMitTA33KSqNXhnbqLUZigRnW84c963SnWR/9SRnJE6NP+qBO0HUS/ zzgUA9A0L1r5Qr7ty0R1QqdzulX0ifCk3yvfTae6PrWGoduYoEC9am6wwrv3VYo0y6sg sj771OgJJtBDlNoZZrS2rU8ji5hBkzgtZCv3o50kV5kqEmYTGiI2NntMezLrGqDTAkwK uzwaMwqp/+hqQnoHFn/MobDdy6/424lD8IOWWr1DPliYIJPrNf8GubC3uj+JsGy8+WrV innFAHoOUdbRF8KBToIS6CS2ahsMN5mLB1rqxv0sP9i8/fKu44sEyBg5tYqd4AjcNqYI r9vg== X-Gm-Message-State: ALoCoQmefY8hkln6GLJ6kki83lR+CtNdpbba5FJvNrdM+LplYVJysqhcFutJAC0irNcjWAPs+t4G X-Received: by 10.182.240.138 with SMTP id wa10mr10074877obc.36.1428179131970; Sat, 04 Apr 2015 13:25:31 -0700 (PDT) From: Bart Schaefer Message-Id: <150404132528.ZM14947@torch.brasslantern.com> Date: Sat, 4 Apr 2015 13:25:28 -0700 In-Reply-To: Comments: In reply to Thorsten Kampe "Re: How to trap EXIT like in bash" (Apr 4, 9:41pm) References: <150404113557.ZM14788@torch.brasslantern.com> <1428167314.5875.2.camel@niobium.home.fifi.org> <150404114859.ZM14898@torch.brasslantern.com> In-Reply-To: Comments: In reply to Thorsten Kampe "Re: How to trap EXIT like in bash" (Apr 4, 9:59pm) X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: How to trap EXIT like in bash MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 4, 9:41pm, Thorsten Kampe wrote: } } > zshexit() { echo trapped } } > trap exit HUP INT TERM } } As stated to Philippe: this works in regard to exit and INT, but not } for HUP and TERM. The script ignores any `kill PID` request. } } Tested on Cygwin and Ubuntu 14.10. Oh. You need "setopt TRAPS_ASYNC": While waiting for a program to exit, handle signals and run traps immediately. Otherwise the trap is run after a child process has exited. Note this does not affect the point at which traps are run for any case other than when the shell is waiting for a child process. The signal isn't ignored, it just isn't handled right away. Normally any foreground child process is the "group leader" and receives the signals before the parent shell. I wonder if this should be on by default in "sh" emulation.