Skip to content
Snippets Groups Projects
Commit 838ff625 authored by Simon McVittie's avatar Simon McVittie
Browse files

adverb: When a fd is passed through, don't hold it open


This is similar to how we deal with stdout, but for fds that have been
passed through, other than stdin (0), stdout (1) and stderr (2).

Part of pressure-vessel#6.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent b99e71cc
No related branches found
No related tags found
No related merge requests found
...@@ -868,6 +868,22 @@ main (int argc, ...@@ -868,6 +868,22 @@ main (int argc,
goto out; goto out;
} }
/* If the parent or child writes to a passed fd and closes it,
* don't stand in the way of that. Skip fds 0 (stdin),
* 1 (stdout) and 2 (stderr); we have moved our original stdout
* to another fd which will be dealt with below, and we want to keep
* our stdin and stderr open. */
if (child_setup_data.pass_fds != NULL)
{
gsize i;
for (i = 0; child_setup_data.pass_fds[i] > -1; i++)
{
if (child_setup_data.pass_fds[i] > 2)
close (child_setup_data.pass_fds[i]);
}
}
g_free (child_setup_data.pass_fds); g_free (child_setup_data.pass_fds);
/* If the child writes to stdout and closes it, don't interfere */ /* If the child writes to stdout and closes it, don't interfere */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment