Implications of setting SIGCHLD in relation to NIFs
Mon Nov 16 18:54:55 CET 2020
I am working on Tensorflow bindings and, at some point, Tensorflow forks a
child process to invoke a separate program. Unfortunately, when running
inside the Erlang VM, Tensorflow fails when calling waitpid, in exactly
After some debugging, we found out the root cause is because the Erlang VM
sets SIGCHLD to SIG_IGN. According to waitpid docs
> If the calling process sets SIGCHLD to SIG_IGN, and the process has no
unwaited for children that were transformed into zombie processes, the
calling thread blocks until all of the children of the process terminate,
at which time waitpid() returns -1 with errno set to ECHILD.
Setting os:set_signal(sigchld, default) fixes the issue, however, it leaves
1. Is it safe to set sigchld back to default? Or is the VM expecting it to
be ignored? Are there any implications we should be aware of?
2. In case it is safe to have it as a default, why is it being ignored in
the first place?
*José Valimhttps://dashbit.co/ <https://dashbit.co/>*
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions