65
65
{ "pass-stdout", no_argument, &pass_stdout, 1 },
66
66
{ NULL, 0, NULL, 0 }
68
69
di_io_handler *stdout_handler = NULL, *stderr_handler = NULL;
69
70
di_process_handler *parent_prepare_handler = NULL;
70
71
di_process_handler *child_prepare_handler = NULL;
98
/* It's possible for subsidiary processes to start daemons which
99
* forget to clean up their file descriptors properly, which means
100
* that polling the other ends of those file descriptors will never
101
* complete. We install a no-op SIGCHLD handler to make sure that
102
* its poll() gets EINTR and gives up.
104
* Technically, this is exploiting a bug in di_exec, and a better
105
* solution would be nice ...
107
sa.sa_handler = &sigchld_handler;
108
sigemptyset(&sa.sa_mask);
109
sa.sa_flags = SA_NOCLDSTOP;
110
sigaction(SIGCHLD, &sa, NULL);
97
112
if (pass_stdout) {
98
/* di_exec is a bit odd, and won't always notice that the
99
* subsidiary process has gone away if a stdout_handler
100
* isn't installed. We install a no-op SIGCHLD handler to
101
* make sure that its poll() gets EINTR and gives up.
103
* Technically, this is exploiting a bug in di_exec, and a
104
* better solution would be nice ...
107
sa.sa_handler = &sigchld_handler;
108
sigemptyset(&sa.sa_mask);
109
sa.sa_flags = SA_NOCLDSTOP;
110
sigaction(SIGCHLD, &sa, NULL);
112
113
orig_stdout = dup(1);
113
114
parent_prepare_handler = &close_orig_stdout;
114
115
child_prepare_handler = &restore_orig_stdout;