Skip to content

Commit

Permalink
tests: Tolerate init process pid != 1.
Browse files Browse the repository at this point in the history
On Ubuntu Saucy based desktops, upstart runs with user sessions
enabled which means that the init process under which a daemon
might run is not always pid = 1.

Instead of checking for pid = 1, check to ensure that the parent
pid of the monitor is not the pid of the shell that started it.

Signed-off-by: James Page <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
javacruft authored and blp committed Jun 20, 2013
1 parent e2711da commit c8dc7b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/daemon-py.at
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ CHECK([kill -0 `cat daemon`])
CHECK([ps -o ppid= -p `cat daemon` > monitor])
CHECK([kill -0 `cat monitor`])
CHECK([ps -o ppid= -p `cat monitor` > init])
CHECK([test `cat init` = 1])
CHECK([test `cat init` != $$])
# Kill the daemon process, making it look like a segfault,
# and wait for a new daemon process to get spawned.
CHECK([cp daemon olddaemon])
Expand All @@ -159,7 +159,7 @@ CHECK([ps -o ppid= -p `cat daemon` > newmonitor])
CHECK([diff monitor newmonitor])
CHECK([kill -0 `cat newmonitor`])
CHECK([ps -o ppid= -p `cat newmonitor` > init])
CHECK([test `cat init` = 1])
CHECK([test `cat init` != $$])
# Kill the daemon process with SIGTERM, and wait for the daemon
# and the monitor processes to go away and the pidfile to get deleted.
CHECK([kill `cat daemon`], [0], [], [ignore])
Expand Down
4 changes: 2 additions & 2 deletions tests/daemon.at
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CHECK([kill -0 `cat daemon`])
CHECK([ps -o ppid= -p `cat daemon` > monitor])
CHECK([kill -0 `cat monitor`])
CHECK([ps -o ppid= -p `cat monitor` > init])
CHECK([test `cat init` = 1])
CHECK([test `cat init` != $$])
# Kill the daemon process, making it look like a segfault,
# and wait for a new daemon process to get spawned.
CHECK([cp daemon olddaemon])
Expand All @@ -121,7 +121,7 @@ CHECK([ps -o ppid= -p `cat daemon` > newmonitor])
CHECK([diff monitor newmonitor])
CHECK([kill -0 `cat newmonitor`])
CHECK([ps -o ppid= -p `cat newmonitor` > init])
CHECK([test `cat init` = 1])
CHECK([test `cat init` != $$])
# Kill the daemon process with SIGTERM, and wait for the daemon
# and the monitor processes to go away and the pidfile to get deleted.
CHECK([kill `cat daemon`], [0], [], [ignore])
Expand Down

0 comments on commit c8dc7b4

Please sign in to comment.