zsh-users
 help / color / mirror / code / Atom feed
From: Andre Albsmeier <Andre.Albsmeier@siemens.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Andre Albsmeier <Andre.Albsmeier@siemens.com>, zsh-users@zsh.org
Subject: Re: exec'ing $0 in traps
Date: Sat, 18 Feb 2017 11:24:22 +0100	[thread overview]
Message-ID: <20170218102422.GA67180@bali> (raw)
In-Reply-To: <170217120219.ZM11847@torch.brasslantern.com>

On Fri, 17-Feb-2017 at 12:02:19 -0800, Bart Schaefer wrote:
> On Feb 17,  9:16am, Andre Albsmeier wrote:
> }
> } #!/bin/zsh
> } 
> } echo started
> } trap 'echo trapped; exec "$0"' 1
> } 
> } echo $$ > /tmp/blafasel
> } 
> } while read line; do
> }   echo line $line
> } done
> 
> Some combination of the "read" builtin plus calling "exec" from inside
> the signal handler is causing the HUP signal to remain blocked across
> the "exec" -- and re-installing the trap doesn't unblock it.

Too bad. Maybe this gets fixed one day. Meanwhile I use this:

#!/bin/zsh

restart=""
echo started

trap 'restart=1' 1

echo $$ > /tmp/blafasel

while :; do
  [ $restart ] && exec $0
  read line || exit 0
  echo line $line          
done


and it seems to do what I need...


      reply	other threads:[~2017-02-18 10:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17  8:16 Andre Albsmeier
2017-02-17 20:02 ` Bart Schaefer
2017-02-18 10:24   ` Andre Albsmeier [this message]

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=20170218102422.GA67180@bali \
    --to=andre.albsmeier@siemens.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@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).