After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 703407 - g_spawn_async() keeps child_pid_report_pipe open in child process
g_spawn_async() keeps child_pid_report_pipe open in child process
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-07-01 17:57 UTC by paul.barbieri
Modified: 2013-07-01 21:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
close child_pid_report_pipe before do_exec() (413 bytes, patch)
2013-07-01 17:57 UTC, paul.barbieri
accepted-commit_now Details | Review
test program (741 bytes, text/x-csrc)
2013-07-01 18:03 UTC, paul.barbieri
  Details

Description paul.barbieri 2013-07-01 17:57:15 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.
Comment 1 paul.barbieri 2013-07-01 18:03:57 UTC
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.
Comment 2 Colin Walters 2013-07-01 20:59:37 UTC
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.