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

Re: kill the LHS command of a pipe once the RHS command terminates



On 2019-06-28 19:41:34 +0100, Stephane Chazelas wrote:
> So here with zsh, you can do:
> 
> zmodload zsh/system
> 
> page-and-kill-cmd() {
>   (echo $sysparams[pid]; "$@") | (
>     IFS= read -r pid
>     ${PAGER:-less}
>     kill -s PIPE $pid
>   )
> }

This is not OK.

zira% page-and-kill-cmd eval 'seq 100'
page-and-kill-cmd:kill:4: kill 24157 failed: no such process

Thus if the left-hand-side process has terminated, this tries to
kill a random process!

-- 
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