You can see the following error in your logs with Zabbix Agent.
8412:20110908:081804.268 Zabbix Agent started. Zabbix 1.8.3 (revision 13928).
8412:20110908:081809.273 Can’t recreate shared memory for collector. [too many attempts]
While it’s not guaranteed, this can be the cause of leftover semaphores. If Zabbix Agent is stopped, try the following.
~# ipcs -a |more
-–-– Shared Memory Segments -–-—-
key shmid owner perms bytes nattch status
0x7402017d 1343488 root 600 4 0
0x74020153 2031617 root 600 4 0
** 0x6c028449 2555906 501 666 1000232 0**
0x74020152 1998851 root 600 4 0
** 0x6c028466 2588676 zabbix 666 1000232 0**
-–-– Semaphore Arrays -–-—-
**key semid owner perms nsems **
**0x7a028449 360448 zabbix 666 7 **
-–-– Message Queues -–-—-
key msqid owner perms used-bytes messages
If all Zabbix Processes are stopped, but there are still semaphores left for that Zabbix user, you can manually remove them. In my case, they remained because of a change in the user (was previously UID 501 (as seen in bold above)). I had to remove those semaphores manually.
First, remove the Shared Memory identifiers:
~# ipcrm -M 0x6c028449
~# ipcrm -M 0x6c028466
Then remove the Semaphore Array:
~# ipcrm -S 0x7a028449
You should be able to start your Zabbix Agent normally now.