zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: frederik@ofb.net, zsh-workers@zsh.org
Subject: Re: exec redirect prevents trap
Date: Sat, 16 Apr 2016 09:34:33 -0700	[thread overview]
Message-ID: <160416093433.ZM24261@torch.brasslantern.com> (raw)
In-Reply-To: <20160416075941.GA27994@ofb.net>

On Apr 16, 12:59am, frederik@ofb.net 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 &! )


  reply	other threads:[~2016-04-16 16:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-16  7:59 frederik
2016-04-16 16:34 ` Bart Schaefer [this message]
2016-04-16 19:13   ` frederik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160416093433.ZM24261@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=frederik@ofb.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).