Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: exec redirect prevents trap
- X-seq: zsh-workers 38292
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: frederik@xxxxxxx, zsh-workers@xxxxxxx
- Subject: Re: exec redirect prevents trap
- Date: Sat, 16 Apr 2016 09:34:33 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=HNybGYID3qQJB++k/m6Em5T2GweW7GPOiHOwojktpb4=; b=u/+daFe5CfEkAIcqpt67tbLSTp5DTdrVSPi3nx6AOWTREwBxJXUE3n1WLJ3GlR0G18 M3zRk2Z7lHn3FdWu1xpxdGThY/sm0k8rv6pqPi+I8sajF+HkpdmzZe0W6OCyRJMV87Y4 VjTyPhCZMYMXkE+0lPOfrQJx3ObpAwBer16ibkZebeS0shtsgycwEdQwj4Lc5boQhNza IR3Wp7og7cLkRdEMdsQs0/P3GQvJxkEWJzFFj3zUxR9TVKkaCN9QiCLpuFFrDJWnUqZ0 MB3IGq8ZqGXE8FT82Vg4E1FZoxvsxI0hgELiM6bO5o3lKW9Njp0IQcmX9ay/EprlvtCv 8ibw==
- In-reply-to: <20160416075941.GA27994@ofb.net>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160416075941.GA27994@ofb.net>
On Apr 16, 12:59am, frederik@xxxxxxx wrote:
}
} #!/bin/zsh
} exec > >(tee -a /tmp/foo)
} trap "echo hi" INT TERM EXIT
} sleep 1d;
}
} When I run it and hit ^C, it doesn't print anything. But when I remove
} the "exec" line and do the same, it prints "hi".
I suspect what you have here is a race condition. When zsh exits,
it first sends a HUP signal to all its children, including the tee
process. If tee dies before the exit trap runs, the "hi" will go
nowhere.
Try one of these:
exec > >(trap '' HUP; tee -a /tmp/foo)
exec > >(tee -a /tmp/foo &! )
Messages sorted by:
Reverse Date,
Date,
Thread,
Author