X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fslocal.c;h=17be186bcd540625e84ad97f0b509698687452ff;hb=bb2dc190d836a871640e68feee28b290e554390d;hp=ff8df8c8280520ee5e08209405c2af03c61a7b11;hpb=fede6e42d81ce34fd5c1bbe7fb2757b281c2573a;p=mmh diff --git a/uip/slocal.c b/uip/slocal.c index ff8df8c..17be186 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -90,7 +90,8 @@ static struct passwd *pw; /* passwd file entry */ static char ddate[BUFSIZ]; /* record the delivery date */ struct tws *now; -static jmp_buf myctx; +volatile sig_atomic_t eflag = 0; /* flag to indecate interrupt */ +static volatile pid_t child_id; /* flags for pair->p_flags */ #define P_NIL 0x00 @@ -980,7 +981,6 @@ usr_folder(int fd, char *string) static int usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress) { - pid_t child_id; int bytes, seconds, status, n; struct stat st; char *path; @@ -1034,16 +1034,6 @@ usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress) default: /* parent process */ - if (setjmp(myctx)) { - /* - ** Ruthlessly kill the child and anything - ** else in its process group. - */ - kill(-child_id, SIGKILL); - if (verbose) - verbose_printf(", timed-out; terminated\n"); - return -1; - } SIGNAL(SIGALRM, alrmser); bytes = fstat(fd, &st) != -1 ? (int) st.st_size : 100; @@ -1061,6 +1051,13 @@ usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress) status = pidwait(child_id, 0); alarm(0); + if (eflag) { + if (verbose) { + verbose_printf(", timed-out; terminated\n"); + } + return -1; + } + if (verbose) { if (!status) { verbose_printf(", success.\n"); @@ -1078,7 +1075,8 @@ usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress) static void alrmser(int i) { - longjmp(myctx, DONE); + eflag = 1; + kill(-child_id, SIGKILL); }