Skip to content

Commit 5790ad9

Browse files
authored
Merge pull request #102 from Bisa/issue/#100-stopping-systemd-started-causes-timeout
Issue/#100 stopping systemd started causes timeout
2 parents 4c5ee00 + d601a60 commit 5790ad9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

factorio

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ start_service() {
197197
stop_service() {
198198
if [ -e ${PIDFILE} ]; then
199199
echo -n "Stopping ${SERVICE_NAME}: "
200-
if kill -TERM $(cat ${PIDFILE}) 2> /dev/null; then
200+
if kill -TERM $(cat ${PIDFILE} 2> /dev/null) 2> /dev/null; then
201201
sec=1
202202
while [ "$sec" -le 15 ]; do
203203
if [ -e ${PIDFILE} ]; then
204-
if kill -0 $(cat ${PIDFILE}) 2> /dev/null; then
204+
if kill -0 $(cat ${PIDFILE} 2> /dev/null) 2> /dev/null; then
205205
echo -n ". "
206206
sleep 1
207207
else
@@ -214,15 +214,22 @@ stop_service() {
214214
done
215215
fi
216216

217-
if kill -0 $(cat ${PIDFILE}) 2> /dev/null; then
217+
if kill -0 $(cat ${PIDFILE} 2> /dev/null) 2> /dev/null; then
218218
echo "Unable to shut down nicely, killing the process!"
219-
kill -KILL $(cat ${PIDFILE}) 2> /dev/null
219+
kill -KILL $(cat ${PIDFILE} 2> /dev/null) 2> /dev/null
220220
else
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)