sys_fork() / sys_getpid()

Jelmer Vernooij jelmer at samba.org
Sat Mar 24 07:43:15 MDT 2012


At the moment we have two trivial wrappers for fork() and getpid() in
lib/util/system.c. These wrappers exist so that we can cache the PID and
avoid a system call when getpid() is called.

Is this optimization actually still worth the trouble these days? We
don't seem to have any regularly called code paths that need it. The
printing code seems to use it as a simple way of identifying a single
server in the database, but that can be worked around by just using a
single variable there.

Furthermore, there is the risk that we end up not updating the pid after
a fork() - thus ending up with sys_getpid() returning the wrong pid. For
example, our libraries are used in various applications, either directly
or as part of e.g. openchange, which don't use sys_fork() but plain fork.

Thoughts?

Cheers,

Jelmer

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20120324/17e84c32/attachment.pgp>


More information about the samba-technical mailing list