Dec 292009

You may receive an error such as the one above while restarting Apache. Most people tend to believe that they are running out of disk space, but that is not the case. The apache error logs will show errors similar to the ones below and you may be surprised to know that this is not necessarily a space issue as shown by the error. You may also notice that apache is not bound to any port. The Apache error logs may show:

semget: No space left on device
Apache: No space left on device: Couldn’t create accept lock

This is about Semaphores. What is a semaphore? Semaphores are used for communicating between active processes.
In this case it is used for communicating between apache parent and child processes. Apache writes down information before the activate processes communicates. If apache is unable to write such things down, the processes are unable to communicate resulting in the above error. Here is the way you can track down the current semaphores and kill those processes.

ipcs -s

This will list all the current semaphore IDs, their owner (httpd or nobody) and their permissions. You can kill those processes using

ipcrm -s PID

If they are plenty in numbers use the below command:

for i in `ipcs -s | awk ‘/httpd/ {print $2}’`; do (ipcrm -s $i); done
for i in `ipcs -s | awk ‘/nobody/ {print $2}’`; do (ipcrm -s $i); done

Apache can now be started without any problems.

 Posted by at 5:21 am