Codebase list sysvinit / 2474772
debian: Close #663009, #699523 and #699566 Remove the use of pidof by not restarting init on Hurd. Also avoid restarts in chroots where ischroot fails. Roger Leigh 11 years ago
2 changed file(s) with 49 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
0 sysvinit (2.88dsf-40) unstable; urgency=low
1
2 [ Roger Leigh ]:
3 * Don't restart init on GNU/Hurd (Closes: #663009).
4 * Handle PID detection more robustly, to work better with containers
5 (Closes: #699523). Always use PID1, which avoids the need for
6 fragile pidof usage.
7 * Handle ischroot more gracefully on failure (Closes: #699566).
8
9 -- Roger Leigh <rleigh@debian.org> Sun, 03 Feb 2013 14:52:05 +0000
10
011 sysvinit (2.88dsf-39) unstable; urgency=low
112
213 [ Roger Leigh ]:
1616 ;;
1717 esac
1818
19 # PID of init; may not always be 1. Use for sending signals
20 # and checking if init is running.
21 PID="$(pidof /sbin/init || echo 1)"
19 # PID of init; may not always be 1 but this code isn't run in
20 # these cases (Hurd). Use for sending signals and checking if
21 # init is running.
22 PID=1
2223
2324 # Create /run/initctl if not present, and also create compatibility
2425 # symlinks
3536 mv "$OLDINITCTL.new" "$OLDINITCTL"
3637
3738 # Reopen control channel (uses new channel).
38 if ! ischroot
39 then
40 kill -s USR1 "$PID"
41 fi
39 kill -s USR1 "$PID"
4240 rm -f /etc/ioctl.save
4341
4442 if [ ! -f /etc/inittab ]
4947 # Tell init to re-exec itself. We loop on failure to reduce
5048 # the chance of a race before the new control channel is
5149 # opened.
52 if ! ischroot
53 then
54 echo -n "sysvinit: restarting..."
55 for delay in 0 1 2 3 4 5 6 fail;
56 do
57 if init u
50 echo -n "sysvinit: restarting..."
51 for delay in 0 1 2 3 4 5 6 fail;
52 do
53 if init u
54 then
55 echo " done."
56 break
57 else
58 if [ "$delay" = "fail" ]
5859 then
59 echo " done."
60 break
60 echo " failed."
6161 else
62 if [ "$delay" = "fail" ]
63 then
64 echo " failed."
65 else
66 echo -n "."
67 sleep "$delay"
68 fi
62 echo -n "."
63 sleep "$delay"
6964 fi
70 done
71 else
72 echo "Not restarting sysvinit: chroot detected"
73 fi
65 fi
66 done
7467
7568 # Remove old pipe if present. No longer in use after re-exec.
7669 if [ -p "$OLDINITCTL" ]
9083
9184 umask 022
9285
86 restart=yes
87
88 chroot=0
89 ischroot || chroot="$?"
90
91 if [ "$chroot" != "1" ]; then
92 restart=no
93 fi
94
9395 # If systemd is running, don't restart init or doing any initctl
9496 # migration.
95 if [ ! -e /sys/fs/cgroup/systemd ] ; then
97 if [ -e /sys/fs/cgroup/systemd ]; then
98 restart=no
99 fi
100 if [ "$(uname -s)" = "GNU" ]; then
101 restart=no
102 fi
103
104 if [ "$restart" = "yes" ]; then
96105 do_restart
106 else
107 echo "Not restarting sysvinit"
97108 fi
98109
99110 #DEBHELPER#