chiark
/
gitweb
/
~mdw
/
qmail
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Upstream qmail 1.03
[qmail]
/
predate.c
diff --git
a/predate.c
b/predate.c
index b011dc55d2886b44d48bf55fa2c23c1708925683..9648f6e4f80910dd17fe45ad25fc99fc90b56b00 100644
(file)
--- a/
predate.c
+++ b/
predate.c
@@
-5,11
+5,14
@@
#include "wait.h"
#include "fd.h"
#include "fmt.h"
#include "wait.h"
#include "fd.h"
#include "fmt.h"
+#include "strerr.h"
#include "substdio.h"
#include "subfd.h"
#include "readwrite.h"
#include "exit.h"
#include "substdio.h"
#include "subfd.h"
#include "readwrite.h"
#include "exit.h"
+#define FATAL "predate: fatal: "
+
static char *montab[12] = {
"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
};
static char *montab[12] = {
"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
};
@@
-34,30
+37,22
@@
char **argv;
sig_pipeignore();
sig_pipeignore();
- if (!argv[1]) {
- substdio_putsflush(subfderr,"predate: usage: predate child\n");
- _exit(100);
- }
+ if (!argv[1])
+ strerr_die1x(100,"predate: usage: predate child");
- if (pipe(pi) == -1) {
- substdio_putsflush(subfderr,"predate: fatal: unable to create pipe\n");
- _exit(111);
- }
+ if (pipe(pi) == -1)
+ strerr_die2sys(111,FATAL,"unable to create pipe: ");
switch(pid = fork()) {
case -1:
switch(pid = fork()) {
case -1:
- substdio_putsflush(subfderr,"predate: fatal: unable to fork\n");
- _exit(111);
+ strerr_die2sys(111,FATAL,"unable to fork: ");
case 0:
close(pi[1]);
case 0:
close(pi[1]);
- if (fd_move(0,pi[0]) == -1) {
- substdio_putsflush(subfderr,"predate: fatal: unable to set up fds\n");
- _exit(111);
- }
+ if (fd_move(0,pi[0]) == -1)
+ strerr_die2sys(111,FATAL,"unable to set up fds: ");
sig_pipedefault();
execvp(argv[1],argv + 1);
sig_pipedefault();
execvp(argv[1],argv + 1);
- substdio_putsflush(subfderr,"predate: fatal: unable to exec\n");
- _exit(111);
+ strerr_die4sys(111,FATAL,"unable to run ",argv[1],": ");
}
close(pi[0]);
substdio_fdbuf(&ss,write,pi[1],outbuf,sizeof(outbuf));
}
close(pi[0]);
substdio_fdbuf(&ss,write,pi[1],outbuf,sizeof(outbuf));
@@
-113,13
+108,9
@@
char **argv;
substdio_flush(&ss);
close(pi[1]);
substdio_flush(&ss);
close(pi[1]);
- if (wait_pid(&wstat,pid) == -1) {
- substdio_putsflush(subfderr,"predate: fatal: wait failed\n");
- _exit(111);
- }
- if (wait_crashed(wstat)) {
- substdio_putsflush(subfderr,"predate: fatal: child crashed\n");
- _exit(111);
- }
+ if (wait_pid(&wstat,pid) == -1)
+ strerr_die2sys(111,FATAL,"wait failed: ");
+ if (wait_crashed(wstat))
+ strerr_die2x(111,FATAL,"child crashed");
_exit(wait_exitcode(wstat));
}
_exit(wait_exitcode(wstat));
}