[systemd-devel] [PATCH] journal: return -ECHILD after a fork

Lennart Poettering lennart at poettering.net
Wed Jul 17 16:25:49 PDT 2013


On Wed, 17.07.13 11:05, Shawn (shawnlandden at gmail.com) wrote:

> Wouldn't this be better using pthread_atfork() to avoid all the getpid()
> calls?

No pthread_atfork() is not useful for much since it gives no ordering
guarantees. 

Threading and forking doesn't mix well, and neither do single-use open
file descriptors.

I am just not interested in the bug reports. fork() on Unix is a very
special thing. The only reason to ever call it is because you want to
invoke exec() in the child quickly. Everything else is just broken, and
slow (page faults due to Cow...) and browsing the journal certainly is
certainly nothing you ever need for preparing before exec().

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list