mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Switch from tee to cat in psub --fifo
Prior to this fix, we would write to a fifo via cat >$filename & . However in some cases (and soon in all cases) we open the file before the fork, not after. This results in a deadlock because the file open cannot succeed until a write begins. Switch to using tee to write to the file. Because tee opens the file itself, fish is no longer responsible and the deadlock is resolved.
This commit is contained in:
parent
dbe906b79e
commit
6c22c8893b
1 changed files with 4 additions and 1 deletions
|
@ -29,7 +29,10 @@ function psub --description "Read from stdin into a file and output the filename
|
|||
or return
|
||||
set filename $dirname/psub.fifo"$_flag_suffix"
|
||||
mkfifo $filename
|
||||
cat >$filename &
|
||||
# Note that if we were to do the obvious `cat >$filename &`, we would deadlock
|
||||
# because $filename may be opened before the fork. Use tee to ensure it is opened
|
||||
# after the fork.
|
||||
tee $filename >/dev/null &
|
||||
else if test -z "$_flag_suffix"
|
||||
set filename (mktemp $tmpdir/.psub.XXXXXXXXXX)
|
||||
cat >$filename
|
||||
|
|
Loading…
Reference in a new issue