diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-01 01:18:20 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-01 01:18:20 +0000 |
commit | 2856dab4770e521a87c18b04ae8ebc209a9b95f9 (patch) | |
tree | d4f6495339702c0b6d79816d0bb07ba4b6679ce8 /runit | |
parent | f443bffd3c24c4b7fcbc0472c75e747e26c24fef (diff) | |
download | busybox-w32-2856dab4770e521a87c18b04ae8ebc209a9b95f9.tar.gz busybox-w32-2856dab4770e521a87c18b04ae8ebc209a9b95f9.tar.bz2 busybox-w32-2856dab4770e521a87c18b04ae8ebc209a9b95f9.zip |
tcpsvd: new applet
It's a GPL-ed 'clone' of Dan Bernstein's tcpserver.
Author: Gerrit Pape <pape@smarden.org>
http://smarden.sunsite.dk/ipsvd/
size tcpsvd.o
text data bss dec hex filename
2571 4 16 2591 a1f tcpsvd.o
Diffstat (limited to 'runit')
-rw-r--r-- | runit/runit_lib.c | 70 | ||||
-rw-r--r-- | runit/runit_lib.h | 23 | ||||
-rw-r--r-- | runit/runsv.c | 6 | ||||
-rw-r--r-- | runit/runsvdir.c | 7 | ||||
-rw-r--r-- | runit/svlogd.c | 6 |
5 files changed, 11 insertions, 101 deletions
diff --git a/runit/runit_lib.c b/runit/runit_lib.c index 4762096b4..fcb66c3db 100644 --- a/runit/runit_lib.c +++ b/runit/runit_lib.c | |||
@@ -385,56 +385,9 @@ int seek_set(int fd,seek_pos pos) | |||
385 | #endif | 385 | #endif |
386 | 386 | ||
387 | 387 | ||
388 | /*** sig_block.c ***/ | ||
389 | |||
390 | void sig_block(int sig) | ||
391 | { | ||
392 | sigset_t ss; | ||
393 | sigemptyset(&ss); | ||
394 | sigaddset(&ss, sig); | ||
395 | sigprocmask(SIG_BLOCK, &ss, NULL); | ||
396 | } | ||
397 | |||
398 | void sig_unblock(int sig) | ||
399 | { | ||
400 | sigset_t ss; | ||
401 | sigemptyset(&ss); | ||
402 | sigaddset(&ss, sig); | ||
403 | sigprocmask(SIG_UNBLOCK, &ss, NULL); | ||
404 | } | ||
405 | |||
406 | void sig_blocknone(void) | ||
407 | { | ||
408 | sigset_t ss; | ||
409 | sigemptyset(&ss); | ||
410 | sigprocmask(SIG_SETMASK, &ss, NULL); | ||
411 | } | ||
412 | |||
413 | |||
414 | /*** sig_catch.c ***/ | ||
415 | |||
416 | void sig_catch(int sig,void (*f)(int)) | ||
417 | { | ||
418 | struct sigaction sa; | ||
419 | sa.sa_handler = f; | ||
420 | sa.sa_flags = 0; | ||
421 | sigemptyset(&sa.sa_mask); | ||
422 | sigaction(sig,&sa, NULL); | ||
423 | } | ||
424 | |||
425 | |||
426 | /*** sig_pause.c ***/ | ||
427 | |||
428 | void sig_pause(void) | ||
429 | { | ||
430 | sigset_t ss; | ||
431 | sigemptyset(&ss); | ||
432 | sigsuspend(&ss); | ||
433 | } | ||
434 | |||
435 | |||
436 | /*** str_chr.c ***/ | 388 | /*** str_chr.c ***/ |
437 | 389 | ||
390 | // strchrnul? | ||
438 | unsigned str_chr(const char *s,int c) | 391 | unsigned str_chr(const char *s,int c) |
439 | { | 392 | { |
440 | char ch; | 393 | char ch; |
@@ -449,24 +402,3 @@ unsigned str_chr(const char *s,int c) | |||
449 | } | 402 | } |
450 | return t - s; | 403 | return t - s; |
451 | } | 404 | } |
452 | |||
453 | |||
454 | /*** wait_nohang.c ***/ | ||
455 | |||
456 | int wait_nohang(int *wstat) | ||
457 | { | ||
458 | return waitpid(-1, wstat, WNOHANG); | ||
459 | } | ||
460 | |||
461 | |||
462 | /*** wait_pid.c ***/ | ||
463 | |||
464 | int wait_pid(int *wstat, int pid) | ||
465 | { | ||
466 | int r; | ||
467 | |||
468 | do | ||
469 | r = waitpid(pid, wstat, 0); | ||
470 | while ((r == -1) && (errno == EINTR)); | ||
471 | return r; | ||
472 | } | ||
diff --git a/runit/runit_lib.h b/runit/runit_lib.h index 9fe4166bc..25aeeaf70 100644 --- a/runit/runit_lib.h +++ b/runit/runit_lib.h | |||
@@ -123,32 +123,9 @@ extern int open_write(const char *); | |||
123 | extern unsigned pmatch(const char *, const char *, unsigned); | 123 | extern unsigned pmatch(const char *, const char *, unsigned); |
124 | 124 | ||
125 | 125 | ||
126 | /*** sig.h ***/ | ||
127 | |||
128 | extern void sig_catch(int,void (*)(int)); | ||
129 | #define sig_ignore(s) (sig_catch((s), SIG_IGN)) | ||
130 | #define sig_uncatch(s) (sig_catch((s), SIG_DFL)) | ||
131 | |||
132 | extern void sig_block(int); | ||
133 | extern void sig_unblock(int); | ||
134 | extern void sig_blocknone(void); | ||
135 | extern void sig_pause(void); | ||
136 | |||
137 | |||
138 | /*** str.h ***/ | 126 | /*** str.h ***/ |
139 | 127 | ||
140 | extern unsigned str_chr(const char *,int); /* never returns NULL */ | 128 | extern unsigned str_chr(const char *,int); /* never returns NULL */ |
141 | 129 | ||
142 | #define str_diff(s,t) strcmp((s), (t)) | 130 | #define str_diff(s,t) strcmp((s), (t)) |
143 | #define str_equal(s,t) (!strcmp((s), (t))) | 131 | #define str_equal(s,t) (!strcmp((s), (t))) |
144 | |||
145 | |||
146 | /*** wait.h ***/ | ||
147 | |||
148 | extern int wait_pid(int *wstat, int pid); | ||
149 | extern int wait_nohang(int *wstat); | ||
150 | |||
151 | #define wait_crashed(w) ((w) & 127) | ||
152 | #define wait_exitcode(w) ((w) >> 8) | ||
153 | #define wait_stopsig(w) ((w) >> 8) | ||
154 | #define wait_stopped(w) (((w) & 127) == 127) | ||
diff --git a/runit/runsv.c b/runit/runsv.c index 018456847..61eb02e64 100644 --- a/runit/runsv.c +++ b/runit/runsv.c | |||
@@ -323,11 +323,11 @@ static void startservice(struct svdir *s) | |||
323 | close(logpipe[0]); | 323 | close(logpipe[0]); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | sig_uncatch(SIGCHLD); | 326 | signal(SIGCHLD, SIG_DFL); |
327 | signal(SIGTERM, SIG_DFL); | ||
327 | sig_unblock(SIGCHLD); | 328 | sig_unblock(SIGCHLD); |
328 | sig_uncatch(SIGTERM); | ||
329 | sig_unblock(SIGTERM); | 329 | sig_unblock(SIGTERM); |
330 | execve(*run, run, environ); | 330 | execvp(*run, run); |
331 | fatal2_cannot(s->islog ? "start log/" : "start ", *run); | 331 | fatal2_cannot(s->islog ? "start log/" : "start ", *run); |
332 | } | 332 | } |
333 | if (s->state != S_FINISH) { | 333 | if (s->state != S_FINISH) { |
diff --git a/runit/runsvdir.c b/runit/runsvdir.c index cce2c5d9c..39929fc49 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c | |||
@@ -97,9 +97,10 @@ static void runsv(int no, const char *name) | |||
97 | prog[0] = (char*)"runsv"; | 97 | prog[0] = (char*)"runsv"; |
98 | prog[1] = (char*)name; | 98 | prog[1] = (char*)name; |
99 | prog[2] = NULL; | 99 | prog[2] = NULL; |
100 | sig_uncatch(SIGHUP); | 100 | if (pgrp) |
101 | sig_uncatch(SIGTERM); | 101 | setsid(); |
102 | if (pgrp) setsid(); | 102 | signal(SIGHUP, SIG_DFL); |
103 | signal(SIGTERM, SIG_DFL); | ||
103 | BB_EXECVP(prog[0], prog); | 104 | BB_EXECVP(prog[0], prog); |
104 | //pathexec_run(*prog, prog, (char* const*)environ); | 105 | //pathexec_run(*prog, prog, (char* const*)environ); |
105 | fatal2_cannot("start runsv ", name); | 106 | fatal2_cannot("start runsv ", name); |
diff --git a/runit/svlogd.c b/runit/svlogd.c index fb834a403..1d6625561 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -143,9 +143,9 @@ static unsigned processorstart(struct logdir *ld) | |||
143 | int fd; | 143 | int fd; |
144 | 144 | ||
145 | /* child */ | 145 | /* child */ |
146 | sig_uncatch(SIGTERM); | 146 | signal(SIGTERM, SIG_DFL); |
147 | sig_uncatch(SIGALRM); | 147 | signal(SIGALRM, SIG_DFL); |
148 | sig_uncatch(SIGHUP); | 148 | signal(SIGHUP, SIG_DFL); |
149 | sig_unblock(SIGTERM); | 149 | sig_unblock(SIGTERM); |
150 | sig_unblock(SIGALRM); | 150 | sig_unblock(SIGALRM); |
151 | sig_unblock(SIGHUP); | 151 | sig_unblock(SIGHUP); |