fork: no need to _exit() on the error case

This commit is contained in:
Hiltjo Posthuma 2015-03-10 20:05:18 +01:00
parent 82bebf8ce7
commit 066a0306a1
4 changed files with 4 additions and 8 deletions

View File

@ -26,8 +26,7 @@ main(int argc, char *argv[])
if (getpgrp() == getpid()) { if (getpgrp() == getpid()) {
switch (fork()) { switch (fork()) {
case -1: case -1:
weprintf("fork:"); eprintf("fork:");
_exit(1);
case 0: case 0:
break; break;
default: default:

3
tar.c
View File

@ -54,8 +54,7 @@ decomp(FILE *fp)
switch (fork()) { switch (fork()) {
case -1: case -1:
weprintf("fork:"); eprintf("fork:");
_exit(1);
case 0: case 0:
dup2(fileno(fp), 0); dup2(fileno(fp), 0);
dup2(fds[1], 1); dup2(fds[1], 1);

3
time.c
View File

@ -41,8 +41,7 @@ main(int argc, char *argv[])
switch ((pid = fork())) { switch ((pid = fork())) {
case -1: case -1:
weprintf("fork:"); eprintf("fork:");
_exit(1);
case 0: case 0:
execvp(argv[0], argv); execvp(argv[0], argv);
savederrno = errno; savederrno = errno;

View File

@ -168,8 +168,7 @@ spawn(void)
switch (fork()) { switch (fork()) {
case -1: case -1:
weprintf("fork:"); eprintf("fork:");
_exit(1);
case 0: case 0:
execvp(*cmd, cmd); execvp(*cmd, cmd);
savederrno = errno; savederrno = errno;