diff options
| author | manuel <manuel@mausz.at> | 2013-02-04 00:08:53 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-02-04 00:08:53 +0100 |
| commit | 69aec538b456402170dc723af417ba5c05389c32 (patch) | |
| tree | e6f34c543f17c6392447ea337b2e2868212424d1 /bouncesaying.c | |
| download | qmail-69aec538b456402170dc723af417ba5c05389c32.tar.gz qmail-69aec538b456402170dc723af417ba5c05389c32.tar.bz2 qmail-69aec538b456402170dc723af417ba5c05389c32.zip | |
qmail 1.03 import
Diffstat (limited to 'bouncesaying.c')
| -rw-r--r-- | bouncesaying.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bouncesaying.c b/bouncesaying.c new file mode 100644 index 0000000..c7d0026 --- /dev/null +++ b/bouncesaying.c | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #include "fork.h" | ||
| 2 | #include "strerr.h" | ||
| 3 | #include "error.h" | ||
| 4 | #include "wait.h" | ||
| 5 | #include "sig.h" | ||
| 6 | #include "exit.h" | ||
| 7 | |||
| 8 | #define FATAL "bouncesaying: fatal: " | ||
| 9 | |||
| 10 | void main(argc,argv) | ||
| 11 | int argc; | ||
| 12 | char **argv; | ||
| 13 | { | ||
| 14 | int pid; | ||
| 15 | int wstat; | ||
| 16 | |||
| 17 | if (!argv[1]) | ||
| 18 | strerr_die1x(100,"bouncesaying: usage: bouncesaying error [ program [ arg ... ] ]"); | ||
| 19 | |||
| 20 | if (argv[2]) { | ||
| 21 | pid = fork(); | ||
| 22 | if (pid == -1) | ||
| 23 | strerr_die2sys(111,FATAL,"unable to fork: "); | ||
| 24 | if (pid == 0) { | ||
| 25 | execvp(argv[2],argv + 2); | ||
| 26 | if (error_temp(errno)) _exit(111); | ||
| 27 | _exit(100); | ||
| 28 | } | ||
| 29 | if (wait_pid(&wstat,pid) == -1) | ||
| 30 | strerr_die2x(111,FATAL,"wait failed"); | ||
| 31 | if (wait_crashed(wstat)) | ||
| 32 | strerr_die2x(111,FATAL,"child crashed"); | ||
| 33 | switch(wait_exitcode(wstat)) { | ||
| 34 | case 0: break; | ||
| 35 | case 111: strerr_die2x(111,FATAL,"temporary child error"); | ||
| 36 | default: _exit(0); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | strerr_die1x(100,argv[1]); | ||
| 41 | } | ||
