According to my understanding, a semaphore should be usable across related processes without it being placed in shared memory. If so, why does the following code deadlock?>
An excellent article on this topic, for future passers-by:
http://blog.superpat.com/2010/07/14/semaphores-on-linux-sem_init-vs-sem_open/