fails, save errno before getting to work on creating an error file.
pid_t pid;
FILE *errfile;
char *fail;
+ int olderrno;
int fd;
if (argv[1] && argv[1][0] == '-' && argv[1][1] == 'v') {
} else {
fail = "fork";
}
+ olderrno = errno;
/* If we got here fork or exec failed, so try to write an
* error message where later mail processors can find it. We
fd = open(newfn, O_WRONLY | O_EXCL | O_CREAT, 0644);
errfile = fdopen(fd, "w");
if (errfile) {
- fprintf(errfile, "%s:%d\n", fail, errno);
+ fprintf(errfile, "%s:%d\n", fail, olderrno);
}
}