Web lists-archives.com

Re: lintian: shlib-read-write-env




On Wed, 01 Feb 2017 at 11:02:08 +0100, Vincent Danjean wrote:
> In an MT context, such a program should probably use setenv between
> the fork and the exec (ie not in MT context)

Calling non-async-signal safe functions after fork but before exec, in
a process that uses threads, is undefined behaviour according to POSIX.
Try not to do that, particularly in portable software.

(It sort-of-mostly-works on glibc in practice.)

The async-signal-safe functions are the same ones it is safe to call
in a POSIX signal handler - basically, those that are syscalls or
very thin wrappers around syscalls.

> or, probably better,
> use exec variants allowing to specify the new environment.

This. Functions that copy the environment and modify the copy,
like GLib's g_get_environ() and g_environ_setenv(), make this a lot
easier.

    S