Skip to content

Commit d601a60

Browse files
committed
prevent echo from hanging when tail already stopped reading the fifo
1 parent 1a965a0 commit d601a60

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

factorio

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,15 @@ stop_service() {
221221
echo "complete!"
222222
fi
223223

224+
# Start the reader (in case tail stopped already)
225+
cat ${FIFO} &
226+
# Open pipe for writing.
227+
exec 3> ${FIFO}
224228
# Write a newline to the pipe, this triggers a SIGPIPE and causes tail to exit
225-
echo "" > ${FIFO}
229+
echo "" >&3
230+
# Close pipe.
231+
exec 3>&-
232+
226233
rm ${PIDFILE} 2> /dev/null
227234
return 0 # we've either shut down gracefully or killed the process
228235
else

0 commit comments

Comments
 (0)