diff options
Diffstat (limited to 'runit')
-rw-r--r-- | runit/svlogd.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/runit/svlogd.c b/runit/svlogd.c index 4458bd787..db3d4c540 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -206,17 +206,22 @@ static void fmt_time_bernstein_25(char *s) | |||
206 | bin2hex(s, (char*)pack, 12); | 206 | bin2hex(s, (char*)pack, 12); |
207 | } | 207 | } |
208 | 208 | ||
209 | static unsigned processorstart(struct logdir *ld) | 209 | static void processorstart(struct logdir *ld) |
210 | { | 210 | { |
211 | char sv_ch; | ||
211 | int pid; | 212 | int pid; |
212 | 213 | ||
213 | if (!ld->processor) return 0; | 214 | if (!ld->processor) return; |
214 | if (ld->ppid) { | 215 | if (ld->ppid) { |
215 | warnx("processor already running", ld->name); | 216 | warnx("processor already running", ld->name); |
216 | return 0; | 217 | return; |
217 | } | 218 | } |
218 | while ((pid = fork()) == -1) | 219 | |
219 | pause2cannot("fork for processor", ld->name); | 220 | /* vfork'ed child trashes this byte, save... */ |
221 | sv_ch = ld->fnsave[26]; | ||
222 | |||
223 | while ((pid = vfork()) == -1) | ||
224 | pause2cannot("vfork for processor", ld->name); | ||
220 | if (!pid) { | 225 | if (!pid) { |
221 | char *prog[4]; | 226 | char *prog[4]; |
222 | int fd; | 227 | int fd; |
@@ -235,7 +240,7 @@ static unsigned processorstart(struct logdir *ld) | |||
235 | bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave); | 240 | bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave); |
236 | fd = xopen(ld->fnsave, O_RDONLY|O_NDELAY); | 241 | fd = xopen(ld->fnsave, O_RDONLY|O_NDELAY); |
237 | xmove_fd(fd, 0); | 242 | xmove_fd(fd, 0); |
238 | ld->fnsave[26] = 't'; | 243 | ld->fnsave[26] = 't'; /* <- that's why we need sv_ch! */ |
239 | fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); | 244 | fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT); |
240 | xmove_fd(fd, 1); | 245 | xmove_fd(fd, 1); |
241 | fd = open_read("state"); | 246 | fd = open_read("state"); |
@@ -257,8 +262,8 @@ static unsigned processorstart(struct logdir *ld) | |||
257 | execv("/bin/sh", prog); | 262 | execv("/bin/sh", prog); |
258 | bb_perror_msg_and_die(FATAL"cannot %s processor %s", "run", ld->name); | 263 | bb_perror_msg_and_die(FATAL"cannot %s processor %s", "run", ld->name); |
259 | } | 264 | } |
265 | ld->fnsave[26] = sv_ch; /* ...restore */ | ||
260 | ld->ppid = pid; | 266 | ld->ppid = pid; |
261 | return 1; | ||
262 | } | 267 | } |
263 | 268 | ||
264 | static unsigned processorstop(struct logdir *ld) | 269 | static unsigned processorstop(struct logdir *ld) |