aboutsummaryrefslogtreecommitdiff
path: root/src/sentinel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sentinel.c')
-rw-r--r--src/sentinel.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index 1d44763..59b89cc 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -128,48 +128,50 @@ wait_loop(pid_t child, int out, int err)
128 log_buffer_read(err, &ebuf); 128 log_buffer_read(err, &ebuf);
129 } 129 }
130 } 130 }
131 _exit(1); 131 _exit(1);
132} 132}
133 133
134pid_t 134pid_t
135start_command(int p[]) 135start_command(int p[])
136{ 136{
137 int errpipe[2], outpipe[2]; 137 int errpipe[2], outpipe[2];
138 pid_t pid; 138 pid_t pid;
139 139
140 xpipe(errpipe); 140 xpipe(errpipe);
141 xpipe(outpipe); 141 xpipe(outpipe);
142 pid = fork(); 142 pid = fork();
143 if (pid == -1) { 143 if (pid == -1) {
144 system_error(errno, "pipe"); 144 system_error(errno, "pipe");
145 return -1; 145 return -1;
146 } 146 }
147 147
148 if (pid == 0) { 148 if (pid == 0) {
149 char *argv[] = { SHELL, "-c", NULL, NULL }; 149 char *argv[] = { SHELL, "-c", NULL, NULL };
150 int i; 150 int i;
151 151
152 runas();
153
152 close(0); 154 close(0);
153 close(1); 155 close(1);
154 close(2); 156 close(2);
155 open("/dev/null", O_RDWR); 157 open("/dev/null", O_RDWR);
156 dup(outpipe[1]); 158 dup(outpipe[1]);
157 dup(errpipe[1]); 159 dup(errpipe[1]);
158 160
159 i = max(max(outpipe[0],outpipe[1]), 161 i = max(max(outpipe[0],outpipe[1]),
160 max(errpipe[0],errpipe[1])); 162 max(errpipe[0],errpipe[1]));
161 while (--i > 2) 163 while (--i > 2)
162 close(i); 164 close(i);
163 165
164 argv[2] = genrc_command; 166 argv[2] = genrc_command;
165 execvp(SHELL, argv); 167 execvp(SHELL, argv);
166 system_error(errno, "failed to exec %s", genrc_program); 168 system_error(errno, "failed to exec %s", genrc_program);
167 exit(127); 169 exit(127);
168 } 170 }
169 171
170 write_pid_file(pid); 172 write_pid_file(pid);
171 173
172 close(outpipe[1]); 174 close(outpipe[1]);
173 close(errpipe[1]); 175 close(errpipe[1]);
174 176
175 p[0] = outpipe[0]; 177 p[0] = outpipe[0];

Return to:

Send suggestions and report system problems to the System administrator.