gnosek/fcgiwrap — pull request #26 by stromnet (2014-08-15 07:38:46+00:00)
Title: Socket cleanup on exit

When using unix sockets, bind() will fail with "Address already in use" if the file already exists. fcgiwrap did not clean up the socket properly on exit, and we failed to restart.

The FreeBSD ports init script did this cleanup manually when "stop" was executed. However, on system reboot, the initscripts are not called, with the result that manual intervention was required on system boot.

Patch tested and works on FreeBSD 10.0, should be tested on other supported platforms as well, but it's pretty straightforward POSIX signal handling, so it should probably be OK I think.

Note that it will still fail to startup if the machine totally crashes; the alternative would be to unlink the socket before trying to bind, but that comes with other concerns.