]> git.tuebingen.mpg.de Git - dss.git/commit
run: Fix exit status in case another dss process is running.
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 16 Jun 2016 21:21:08 +0000 (23:21 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 13 Jul 2017 20:54:03 +0000 (22:54 +0200)
commit6c63f45a9068107cfd80aa181134574dd9373c0b
tree4e58116438858044054d99135b376d09bb52626f
parent727cf8701027f1d043f75941417dcf315ce5f875
run: Fix exit status in case another dss process is running.

In daemon mode, we must acquire the semaphore lock in the child process
because the child does not inherit semaphore adjustments. Currently
the parent exits successfully after the fork, so the command appears
to succeed even if the child dies immediately because it was unable
to acquire the lock because another dss process is holding the lock.

This commit introduces a mechanism which enables the parent to tell
whether the child completed its setup successfully. We create a
pipe prior to calling fork(2), and let the child write to one end
of the pipe after setup is complete and just before it enters the
main select loop. The parent reads from the other end of the pipe
and exits once the read(2) call returns. If the child dies early,
read(2) returns zero, indicating failure.
daemon.c
daemon.h
dss.c