mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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:
1 parent
ca7a6b3eb2
commit
ffb7e747bc
2 files changed
+15
-1
No files matched your search
@@ -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
@@ -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);
|
||||
|
||||