GNOME Bugzilla – Bug 703407
g_spawn_async() keeps child_pid_report_pipe open in child process
Last modified: 2013-07-01 21:00:02 UTC
Created attachment 248173 [details] [review] close child_pid_report_pipe before do_exec() The intermediate_child code path in fork_exec_with_pipes() routine keeps the child_pid_report_pipe open in the grandchild process. I have verified this in glib-2.34.3 and glib-2.28.7. I have supplied a patch that calls close_and_invalidate() just prior to the do_exec() call in the grandchild process.
Created attachment 248175 [details] test program This is a test program that calls g_spawn_async() demonstrating the problem. The program can be compiled and linked with this command: gcc -o g_spawn_async_test `pkg-config --cflags glib-2.0` g_spawn_async_test.c `pkg-config --libs glib-2.0` The program is run with no arguments. The program creates a child process exec'ing the program again with the -c argument telling it to act as child process. The parent process will print the pid of the child. The child will continue to execute allowing you to ls -l /proc/<pid>/fd and see the pipe still open. When I run the program, the fd is 6. You will have to manually kill the child process via the kill command.
Review of attachment 248173 [details] [review]: Looks correct, thanks. For any future patches, please see: https://live.gnome.org/GnomeLove/SubmittingPatches For how you can use git to write a commit message and such.
https://git.gnome.org/browse/glib/commit/?id=e55ccf7338f2eb68f08d648855a4a92a091df690