exec: fix potential deadlock after fork()
authorDaniel Vrátil <daniel.vratil@avast.com>
Wed, 12 Sep 2018 15:05:31 +0000 (17:05 +0200)
committerFlorian Forster <octo@collectd.org>
Tue, 9 Oct 2018 12:42:21 +0000 (14:42 +0200)
POSIX forbids calling functions which are not thread-safe like
setenv() after fork() in multi-threaded programs. It happens to
work just fine with some libc implementations, but it causes a
deadlock in the child process with uClibc for example.

The proper way to pass new environment variables to the child
process is to update parent's environment before the fork(), so
that the child inherits the updated environment and then undo the
changes in the parent process again.

Signed-off-by: Florian Forster <octo@collectd.org>

No differences found