[systemd-devel] Need advice on daemon's architecture

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Nov 4 06:57:20 PST 2013


On 04/11/13 14:42, Lennart Poettering wrote:
> A lot of (library)
> code is not happy with being initialized in one process and being
> used in another forked off one.

For what it's worth, fork(3posix) also notes this:

* A process shall be created with a single thread. If a multi-threaded
  process calls fork(), the new process shall contain a replica of the
  calling thread and its entire address space, possibly including  the
  states  of  mutexes  and  other  resources.   Consequently, to avoid
  errors, the child process may only execute async-signal-safe  opera‐
  tions  until  such  time  as  one  of  the exec functions is called.

See Linux signal(7) for a list of async-signal-safe operations: it's not
as long a list as you might hope, and mostly contains syscalls. In
particular, malloc() is not on the list, which rules out a lot of
library code...

    S



More information about the systemd-devel mailing list