vm/os-unix.cpp: set pipe file descriptors to close on exec
parent
c447ca5427
commit
5378f2a0c7
|
@ -324,28 +324,28 @@ void *stdin_loop(void *arg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void open_console()
|
||||
void safe_pipe(int *in, int *out)
|
||||
{
|
||||
int filedes[2];
|
||||
|
||||
if(pipe(filedes) < 0)
|
||||
fatal_error("Error opening control pipe",errno);
|
||||
fatal_error("Error opening pipe",errno);
|
||||
|
||||
control_read = filedes[0];
|
||||
control_write = filedes[1];
|
||||
*in = filedes[0];
|
||||
*out = filedes[1];
|
||||
|
||||
if(pipe(filedes) < 0)
|
||||
fatal_error("Error opening size pipe",errno);
|
||||
if(fcntl(*in,F_SETFD,FD_CLOEXEC) < 0)
|
||||
fatal_error("Error with fcntl",errno);
|
||||
|
||||
size_read = filedes[0];
|
||||
size_write = filedes[1];
|
||||
|
||||
if(pipe(filedes) < 0)
|
||||
fatal_error("Error opening stdin pipe",errno);
|
||||
|
||||
stdin_read = filedes[0];
|
||||
stdin_write = filedes[1];
|
||||
if(fcntl(*out,F_SETFD,FD_CLOEXEC) < 0)
|
||||
fatal_error("Error with fcntl",errno);
|
||||
}
|
||||
|
||||
void open_console()
|
||||
{
|
||||
safe_pipe(&control_read,&control_write);
|
||||
safe_pipe(&size_read,&size_write);
|
||||
safe_pipe(&stdin_read,&stdin_write);
|
||||
start_thread(stdin_loop,NULL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue