=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/calendar/io.c,v retrieving revision 1.45 retrieving revision 1.47 diff -u -r1.45 -r1.47 --- src/usr.bin/calendar/io.c 2017/08/10 14:26:31 1.45 +++ src/usr.bin/calendar/io.c 2017/09/25 19:13:56 1.47 @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.45 2017/08/10 14:26:31 tb Exp $ */ +/* $OpenBSD: io.c,v 1.47 2017/09/25 19:13:56 krw Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -385,6 +385,7 @@ struct stat sbuf; int nread, pdes[2], status; char buf[1024]; + pid_t pid = -1; if (!doall) return; @@ -394,7 +395,7 @@ goto done; if (pipe(pdes) < 0) goto done; - switch (vfork()) { + switch ((pid = vfork())) { case -1: /* error */ (void)close(pdes[0]); (void)close(pdes[1]); @@ -421,8 +422,12 @@ (void)write(pdes[1], buf, nread); (void)close(pdes[1]); done: (void)fclose(fp); - while (wait(&status) >= 0) - ; + if (pid != -1) { + while (waitpid(pid, &status, 0) == -1) { + if (errno != EINTR) + break; + } + } }