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 <james.page@ubuntu.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
CHECK([ps -o ppid= -p `cat daemon` > monitor])
CHECK([kill -0 `cat monitor`])
CHECK([ps -o ppid= -p `cat monitor` > init])
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])
# Kill the daemon process, making it look like a segfault,
# and wait for a new daemon process to get spawned.
CHECK([cp daemon olddaemon])
CHECK([diff monitor newmonitor])
CHECK([kill -0 `cat newmonitor`])
CHECK([ps -o ppid= -p `cat newmonitor` > init])
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])
# 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])
CHECK([ps -o ppid= -p `cat daemon` > monitor])
CHECK([kill -0 `cat monitor`])
CHECK([ps -o ppid= -p `cat monitor` > init])
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])
# Kill the daemon process, making it look like a segfault,
# and wait for a new daemon process to get spawned.
CHECK([cp daemon olddaemon])
CHECK([diff monitor newmonitor])
CHECK([kill -0 `cat newmonitor`])
CHECK([ps -o ppid= -p `cat newmonitor` > init])
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])
# 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])