[Bug libfortran/90038] execute_command_line should not use fork()
jb at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 20 17:43:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90038
--- Comment #11 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Mon May 20 17:43:05 2019
New Revision: 271427
URL: https://gcc.gnu.org/viewcvs?rev=271427&root=gcc&view=rev
Log:
libfortran/90038 Use posix_spawn, reap dead children when wait=.false.
Backport from trunk.
When using posix_spawn or fork to launch a child process, the parent
needs to wait for the child, otherwise the dead child is left as a
zombie process. For this purpose one can install a signal handler for
SIGCHLD.
2019-05-20 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/90038
* intrinsics/execute_command_line (sigchld_handler): New function.
(execute_command_line): Install handler for SIGCHLD.
* configure.ac: Check for presence of sigaction and waitpid.
* config.h.in: Regenerated.
* configure: Regenerated.
fork() semantics can be problematic. Most unix style OS'es have
posix_spawn which can be used to replace fork + exec in many cases.
For more information see
e.g.
https://www.microsoft.com/en-us/research/uploads/prod/2019/04/fork-hotos19.pdf
This replaces the one use of fork in libgfortran with posix_spawn.
2019-05-20 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/90038
* configure.ac (AC_CHECK_FUNCS_ONCE): Check for posix_spawn.
* intrinsics/execute_command_line (execute_command_line): Use
posix_spawn.
* Makefile.in: Regenerated.
* config.h.in: Regenerated.
* configure: Regenerated.
Regtested on x86_64-pc-linux-gnu.
Modified:
branches/gcc-9-branch/libgfortran/ChangeLog
branches/gcc-9-branch/libgfortran/Makefile.in
branches/gcc-9-branch/libgfortran/config.h.in
branches/gcc-9-branch/libgfortran/configure
branches/gcc-9-branch/libgfortran/configure.ac
branches/gcc-9-branch/libgfortran/intrinsics/execute_command_line.c
More information about the Gcc-bugs
mailing list