Hello,
I can't manage to capture signals from a script which is reading from a
named pipe.
Script:
function --on-signal SIGTERM on-signal-sigterm
echo "SIGTERM captured"
end
set fifo /tmp/asd.fifo
echo "fifo reader [" %self "]"
while test ! -p $fifo
echo "$fifo is not a fifo" >&2
sleep 1
end
while true
if read --local line < $fifo
echo "line: $line" &
end
end
Test:
$ rm -f /tmp/asd.txt; and fish daemon.fish
> fifo reader [ 15853 ]
> /tmp/asd.fifo is not a fifo
> ...
$ kill -SIGTERM 15853 [in another shell]
> SIGTERM captured
> /tmp/asd.fifo is not a fifo
> ...
$ mkfifo /tmp/asd.fifo
$ kill -SIGTERM 15853 [in another shell]
> [nothing]
The bash version works, so I guess it is a fish problem:
Script:
trap "echo SIGTERM captured" SIGTERM
fifo=/tmp/asd.fifo
echo "fifo reader [" $$ "]"
while [[ ! -p $fifo ]]; do
echo "$fifo is not a fifo" >&2
sleep 1
done
while true; do
if read line < $fifo; then
echo "line: $line" &
fi
done
Test:
$ rm -f /tmp/asd.txt; and fish daemon.bash
> fifo reader [ 15853 ]
> /tmp/asd.fifo is not a fifo
> ...
$ kill -SIGTERM 15853 [in another shell]
> SIGTERM captured
> /tmp/asd.fifo is not a fifo
> ...
$ mkfifo /tmp/asd.fifo
$ kill -SIGTERM 15853 [in another shell]
> daemon.bash: line 13: /tmp/asd.fifo: Interrupted system call
> SIGTERM captured
Furthermore, I can't Ctrl+C while reading from named pipe on fish, I guess
because SIGINT is not captured too. kill -9 works.
I opened a StackOverflow question for this:
http://stackoverflow.com/questions/22461054/fish-shell-capture-signals-while-reading-from-named-pipeNobody
noticed it, so if you want you can answer it and I will be glad to
give you some points :)
--
Maurizio De Santis
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users