When restarting sshd using the /etc/rc.d/init.d/sshd script
the restart fails when the person doing the restart is logged
in through ssh.
In /etc/rc.d/init.d/functions the daemon() function does a check
for whether any proceses with the same executable name is
currently running by doing:
# See if it's already running.
for apid in $pidlist ; do
[ -d /proc/$apid ] && pid="$pid $apid"
[ -n "$pid" ] && return
However, when you are logged in by ssh to the machine and you
try to restart sshd, there IS a process called /usr/sbin/sshd running
so the daemon function"returns" without actually doing anything.
I can see how this might be a good idea sometimes, however, in this
case it makes the script useless for anyone running headless boxes,
and makes it easy to get stuck with a machine with no way to login to.
(the restart fails, but you don't notice and then logout of the one ssh
shell you currently have---then you can never login until a reboot)
I'm not sure of the best way to fix this except to remove the check and
individual scripts check for other running instances if they want.
I think this is a serious problem. Changing Priority to "high".
My workaround: Build a script...
sleep 1m #Sleep for 1 minute to allow time for user to log off.
service sshd restart #now restart, no sshd processes should be running
This was fixed, among other things, in errata OpenSSH 2.2.0p1-5.
Also, from the initscripts point of view, I don't think there's much better way of checking
whether a daemon is running. _Some_ sort of method should be in initscripts --
if some daemon needs special attention, it should probably be done there then.