Skip to content
Snippets Groups Projects
Commit 0144fe50 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Some minor fixes to Process.create_process().

Rev: src/signal_handler.c:1.94
parent cb08c65b
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "builtin_functions.h" #include "builtin_functions.h"
#include <signal.h> #include <signal.h>
RCSID("$Id: signal_handler.c,v 1.93 1998/11/29 22:09:43 grubba Exp $"); RCSID("$Id: signal_handler.c,v 1.94 1998/11/29 23:17:32 grubba Exp $");
#ifdef HAVE_PASSWD_H #ifdef HAVE_PASSWD_H
# include <passwd.h> # include <passwd.h>
...@@ -1421,6 +1421,10 @@ void f_create_process(INT32 args) ...@@ -1421,6 +1421,10 @@ void f_create_process(INT32 args)
UNSET_ONERROR(err); UNSET_ONERROR(err);
if(pid == -1) { if(pid == -1) {
/*
* fork() failed
*/
close(control_pipe[0]); close(control_pipe[0]);
close(control_pipe[1]); close(control_pipe[1]);
...@@ -1434,7 +1438,11 @@ void f_create_process(INT32 args) ...@@ -1434,7 +1438,11 @@ void f_create_process(INT32 args)
error("Failed to start process.\n" error("Failed to start process.\n"
"errno:%d\n", errno); "errno:%d\n", errno);
} else if(pid) { } else if(pid) {
/* Close our childs end of the pipe. */ /*
* The parent process
*/
/* Close our child's end of the pipe. */
close(control_pipe[1]); close(control_pipe[1]);
free_perishables(&storage); free_perishables(&storage);
...@@ -1465,13 +1473,15 @@ void f_create_process(INT32 args) ...@@ -1465,13 +1473,15 @@ void f_create_process(INT32 args)
while (((e = write(control_pipe[0], buf, 1)) < 0) && (errno == EINTR)) while (((e = write(control_pipe[0], buf, 1)) < 0) && (errno == EINTR))
; ;
/* Wait for exec. */ /* Wait for exec or error */
while (((e = read(control_pipe[0], buf, 3)) < 0) && (errno == EINTR)) while (((e = read(control_pipe[0], buf, 3)) < 0) && (errno == EINTR))
; ;
close(control_pipe[0]); close(control_pipe[0]);
if (!e) { if (!e) {
/* OK! */ /* OK! */
pop_n_elems(args);
push_int(0); push_int(0);
return;
} else { } else {
/* Something went wrong. */ /* Something went wrong. */
switch(buf[0]) { switch(buf[0]) {
...@@ -1516,6 +1526,9 @@ void f_create_process(INT32 args) ...@@ -1516,6 +1526,9 @@ void f_create_process(INT32 args)
} }
} }
}else{ }else{
/*
* The child process
*/
ONERROR oe; ONERROR oe;
#ifdef DECLARE_ENVIRON #ifdef DECLARE_ENVIRON
...@@ -1524,7 +1537,7 @@ void f_create_process(INT32 args) ...@@ -1524,7 +1537,7 @@ void f_create_process(INT32 args)
extern void my_set_close_on_exec(int,int); extern void my_set_close_on_exec(int,int);
extern void do_set_close_on_exec(void); extern void do_set_close_on_exec(void);
/* Close our parents end of the pipe. */ /* Close our parent's end of the pipe. */
close(control_pipe[0]); close(control_pipe[0]);
/* Ensure that the pipe will be closed when the child starts. */ /* Ensure that the pipe will be closed when the child starts. */
set_close_on_exec(control_pipe[1], 1); set_close_on_exec(control_pipe[1], 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment