FILE *cf;
const char *args[10];
#ifdef COMPRESS_OPTIONS
- char opts[80];
+ char opts[sizeof COMPRESS_OPTIONS];
#endif
int i = 0;
- int f;
+ int f, childstatus;
unsigned ln;
#ifdef TTY_GRAPHICS
boolean istty = WINDOWPORT(tty);
free((genericptr_t) cfn);
return;
}
+
+ /*
+ * back in parent...
+ */
#ifndef NO_SIGNAL
- i = 0; /* wait() will update this, hopefully just setting it back to 0 */
+ childstatus = 1; /* wait() should update this, ideally setting it to 0 */
(void) signal(SIGINT, SIG_IGN);
(void) signal(SIGQUIT, SIG_IGN);
- /* wait() returns child's pid or -1, sets 'i' to child's exit status */
- (void) wait((int *) &i);
+ errno = 0; /* avoid stale details if wait() doesn't set errno */
+ /* wait() returns child's pid and sets 'childstatus' to child's
+ exit status, or returns -1 and leaves 'childstatus' unmodified */
+ if ((long) wait((int *) &childstatus) == -1L) {
+ char numbuf[40];
+ const char *details = strerror(errno);
+
+ if (!details) {
+ Sprintf(numbuf, "(%d)", errno);
+ details = numbuf;
+ }
+ raw_printf("Wait when %scompressing %s failed; %s.",
+ uncomp ? "un" : "", filename, details);
+ }
(void) signal(SIGINT, (SIG_RET_TYPE) done1);
if (wizard)
(void) signal(SIGQUIT, SIG_DFL);
* compression if there are no signals, but we want this for
* testing with FailSafeC
*/
- i = 1;
+ childstatus = 1; /* non-zero => failure */
#endif
- if (i == 0) {
+ if (childstatus == 0) {
/* (un)compress succeeded: remove file left behind */
if (uncomp)
(void) unlink(cfn);