s/qmail 4.3.20
Next generation secure email transport
Loading...
Searching...
No Matches
bouncesaying.c
Go to the documentation of this file.
1#include <unistd.h>
2#include "logmsg.h"
3#include "buffer.h"
4#include "wait.h"
5#include "sig.h"
6#include "exit.h"
7
8#define WHO "bouncesaying"
9
10int main(int argc,char * const *argv)
11{
12 int pid;
13 int wstat;
14
15 if (!argv[1])
16 logmsg(WHO,100,USAGE,"bouncesaying error [ program [ arg ... ] ]");
17
18 if (argv[2]) {
19 pid = fork();
20 if (pid == -1)
21 logmsg(WHO,111,FATAL,"unable to fork: ");
22 if (pid == 0) {
23 execvp(argv[2],argv + 2);
24 if (errno) _exit(111);
25 _exit(100);
26 }
27 if (wait_pid(&wstat,pid) == -1)
28 logmsg(WHO,111,FATAL,"wait failed");
29 if (wait_crashed(wstat))
30 logmsg(WHO,111,FATAL,"child crashed");
31 switch (wait_exitcode(wstat)) {
32 case 0: break;
33 case 111: logmsg(WHO,111,FATAL,"temporary child error");
34 default: _exit(0);
35 }
36 }
37
38 buffer_puts(buffer_2,WHO);
39 buffer_puts(buffer_2,": ");
40 buffer_puts(buffer_2,argv[1]);
41 buffer_puts(buffer_2,"\n");
42 buffer_flush(buffer_2);
43 _exit(100);
44}
#define WHO
Definition: bouncesaying.c:8
int main()
Definition: chkshsgr.c:6
void _exit(int)