Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: prompt update and TRAPCHLD



On 2016-01-21 11:13:55 -0800, Bart Schaefer wrote:
> The rule actually is that traps are executed as early as it is "safe" to
> do so (memory management, etc.), and one of those times is immediately
> before another command is going to be run; so the trap could execute for
> example at any time during your precmd function, or during zle-line-init,
> etc.
> 
> So in that sense yes, there is a race condition.

The following code solves it:

updprompt()
{
  unset _trapchld_called
  [...]
  [[ -n $_trapchld_called ]] && updprompt
}

TRAPCHLD()
{
  if [[ -o interactive && -n $TTY ]] then
    {
      updprompt
      typeset -g _trapchld_called=1
    }
  fi
}

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author