version 1.46, 2017/08/21 21:41:13 |
version 1.50, 2021/10/24 21:24:16 |
|
|
if (!(chdir(home) == 0 && |
if (!(chdir(home) == 0 && |
chdir(calendarHome) == 0 && |
chdir(calendarHome) == 0 && |
(fdin = open(calendarFile, O_RDONLY)) != -1)) |
(fdin = open(calendarFile, O_RDONLY)) != -1)) |
errx(1, "no calendar file: ``%s'' or ``~/%s/%s''", |
errx(1, "no calendar file: \"%s\" or \"~/%s/%s\"", |
calendarFile, calendarHome, calendarFile); |
calendarFile, calendarHome, calendarFile); |
} |
} |
} |
} |
|
|
if (pipe(pdes) < 0) { |
if (pipe(pdes) == -1) { |
close(fdin); |
close(fdin); |
return (NULL); |
return (NULL); |
} |
} |
|
|
*/ |
*/ |
if (doall) { |
if (doall) { |
int fderr; |
int fderr; |
fderr = open(_PATH_DEVNULL, O_WRONLY, 0); |
fderr = open(_PATH_DEVNULL, O_WRONLY); |
if (fderr == -1) |
if (fderr == -1) |
_exit(0); |
_exit(0); |
(void)dup2(fderr, STDERR_FILENO); |
(void)dup2(fderr, STDERR_FILENO); |
|
|
struct stat sbuf; |
struct stat sbuf; |
int nread, pdes[2], status; |
int nread, pdes[2], status; |
char buf[1024]; |
char buf[1024]; |
pid_t pid; |
pid_t pid = -1; |
|
|
if (!doall) |
if (!doall) |
return; |
return; |
|
|
(void)rewind(fp); |
(void)rewind(fp); |
if (fstat(fileno(fp), &sbuf) || !sbuf.st_size) |
if (fstat(fileno(fp), &sbuf) || !sbuf.st_size) |
goto done; |
goto done; |
if (pipe(pdes) < 0) |
if (pipe(pdes) == -1) |
goto done; |
goto done; |
switch ((pid = vfork())) { |
switch ((pid = vfork())) { |
case -1: /* error */ |
case -1: /* error */ |
|
|
(void)write(pdes[1], buf, nread); |
(void)write(pdes[1], buf, nread); |
(void)close(pdes[1]); |
(void)close(pdes[1]); |
done: (void)fclose(fp); |
done: (void)fclose(fp); |
while (waitpid(pid, &status, 0) == -1) { |
if (pid != -1) { |
if (errno != EINTR) |
while (waitpid(pid, &status, 0) == -1) { |
break; |
if (errno != EINTR) |
|
break; |
|
} |
} |
} |
} |
} |
|
|