ioemu: Close file descriptors when forking processes.

Just leave stdin/stdout/stderr (and possibly tap fd) open.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
kfraser@localhost.localdomain committed 2007-03-06 16:51:42 +00:00
1 parent ca7a6b3eb2
commit ffb7e747bc
2 files changed
+15 -1

No files matched your search

+8
View File
@@ -3250,6 +3250,14 @@ static int net_tap_init(VLANState *vlan, const char *ifname1,
pid = fork();
if (pid >= 0) {
if (pid == 0) {
int open_max = sysconf(_SC_OPEN_MAX), i;
for (i = 0; i < open_max; i++)
if (i != STDIN_FILENO &&
i != STDOUT_FILENO &&
i != STDERR_FILENO &&
i != fd)
close(i);
parg = args;
*parg++ = (char *)setup_script;
*parg++ = ifname;
+7 -1
View File
@@ -1445,7 +1445,7 @@ int vnc_display_init(DisplayState *ds, int display, int find_unused, struct sock
int vnc_start_viewer(int port)
{
int pid;
int pid, i, open_max;
char s[16];
sprintf(s, ":%d", port);
@@ -1456,6 +1456,12 @@ int vnc_start_viewer(int port)
exit(1);
case 0: /* child */
open_max = sysconf(_SC_OPEN_MAX);
for (i = 0; i < open_max; i++)
if (i != STDIN_FILENO &&
i != STDOUT_FILENO &&
i != STDERR_FILENO)
close(i);
execlp("vncviewer", "vncviewer", s, NULL);
fprintf(stderr, "vncviewer execlp failed\n");
exit(1);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.