upstart doesn’t start sh on first run, starts on subsequent runs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
upstart (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Here’s an Upstart job, saved as /etc/init/r2.conf:
setuid rtorrent
exec screen -S rtorrent -fn -Dm rtorrent -n -o import=/tmp/rtconf
(rtorrent and screen are available from Ubuntu repositories.)
The first time I start it, everything is fine:
# touch /tmp/rtconf <-- creating empty config; needed only once
# service r2 start
r2 start/running, process 1007
# ps aux | grep rtorrent
rtorrent 1007 0.0 0.3 24132 1520 ? Ss 20:13 0:00 SCREEN -S rtorrent -fn -Dm rtorrent -n -o import=/tmp/rtconf
rtorrent 1008 0.2 1.2 262016 6388 pts/1 Ssl+ 20:13 0:00 rtorrent -n -o import=/tmp/rtconf
# service r2 stop
r2 stop/waiting
# ps aux | grep rtorrent
<nothing>
However, when I start it for the second time, “sh” appears from nowhere:
# service r2 start
r2 start/running, process 1021
# ps aux | grep rtorrent
rtorrent 1021 0.0 0.1 4436 628 ? Ss 20:14 0:00 /bin/sh -e -c screen -S rtorrent -fn -Dm rtorrent -n -o import=/tmp/rtconf /bin/sh
rtorrent 1022 0.0 0.3 24132 1524 ? Ss 20:14 0:00 SCREEN -S rtorrent -fn -Dm rtorrent -n -o import=/tmp/rtconf
rtorrent 1023 0.0 1.2 262016 6428 pts/2 Ssl+ 20:14 0:00 rtorrent -n -o import=/tmp/rtconf
What’s worse, due to this it doesn’t stop as expected:
# service r2 stop
r2 stop/waiting
# ps aux | grep rtorrent
rtorrent 1022 0.0 0.3 24132 1524 ? Ss 20:14 0:00 SCREEN -S rtorrent -fn -Dm rtorrent -n -o import=/tmp/rtconf
rtorrent 1023 0.0 1.2 262016 6428 pts/2 Ssl+ 20:14 0:00 rtorrent -n -o import=/tmp/rtconf
The version of Ubuntu I’m using is 13.04 x64. The version of Upstart is 1.8-0ubuntu1.
Strangely enough, a possible workaround is to wrap “exec…” in “script … end script”.