mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 15:20:08 +01:00
setenv() cannot be called after fork, because it might allocate memory,
which can deadlock.
Instead, prepare the environment and use execvpe().
`man 2 fork` says:
After a fork() in a multithreaded program, the child can safely call
only async-signal-safe functions (see signal-safety(7)) until such time
as it calls execve(2).
This means, we are quite strongly limited what can be done in the child
process, before exec. setenv() is not listed as async-signal-safe, obviously
because it allocates memory, and malloc() isn't async-signal-safe either.
See also glib's documentation of GSpawnChildSetupFunc ([1]) about what
can be done in the child process.
[1]
|
||
|---|---|---|
| .. | ||
| agent.c | ||
| common.c | ||
| common.h | ||
| connections.c | ||
| connections.h | ||
| devices.c | ||
| devices.h | ||
| general.c | ||
| generate-docs-nm-settings-nmcli.c | ||
| generate-docs-nm-settings-nmcli.xml.in | ||
| meson.build | ||
| nmcli-completion | ||
| nmcli.c | ||
| nmcli.h | ||
| polkit-agent.c | ||
| polkit-agent.h | ||
| README.md | ||
| settings.c | ||
| settings.h | ||
| utils.c | ||
| utils.h | ||