This may be similar, but the reverse, of another question I asked. In that question, the issue was the service was running but not yet listening on the port. That I can understand, but this situation makes less sense to me: my service has already stopped, but is still listening.
Almost every time I go to restart my development Apache 2.2 service on my CentOS 6.4 box--if it's been some undefined amount of time or hits or something since the last restart--I have to do it twice, because it's still listening. Thereafter it seems to work fine.
$ sudo service httpd-dev restart
[sudo] password for kev:
Stopping httpd: [ OK ]
Starting httpd: (98)Address already in use: make_sock: could not bind to address 192.168.99.44:80
no listening sockets available, shutting down
Unable to open logs
[FAILED]
$ sudo service httpd-dev restart
Stopping httpd: cat: /var/run/httpd/httpd-dev-80.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
[FAILED]
Starting httpd: [ OK ]
$ sudo service httpd-dev restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
How can this be? Doesn't it stop listening the moment the service script shuts it down?
If I put a
sleep 1
line betweenstop
andstart
in theinit.d
script, the problem goes away. Perhaps the main httpd process has shut down but the child processes are still somehow listening for an extra moment.