diff options
author | Karel Zak | 2018-02-01 15:40:43 +0100 |
---|---|---|
committer | Karel Zak | 2018-02-01 15:40:43 +0100 |
commit | 62fa0883be6b2a51f8e69275c4cb31557e84b79f (patch) | |
tree | c8026ea7c0817801ac924bc7fd166e112958c5f6 /text-utils | |
parent | lib/exec_shell: (and pager) use errexec() (diff) | |
download | kernel-qcow2-util-linux-62fa0883be6b2a51f8e69275c4cb31557e84b79f.tar.gz kernel-qcow2-util-linux-62fa0883be6b2a51f8e69275c4cb31557e84b79f.tar.xz kernel-qcow2-util-linux-62fa0883be6b2a51f8e69275c4cb31557e84b79f.zip |
text-utils: use errexec()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils')
-rw-r--r-- | text-utils/more.c | 4 | ||||
-rw-r--r-- | text-utils/pg.c | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/text-utils/more.c b/text-utils/more.c index cbff39b11..0b2db22f3 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -1619,6 +1619,7 @@ void execute(char *filename, char *cmd, ...) for (n = 10; (id = fork()) < 0 && n > 0; n--) sleep(5); if (id == 0) { + int errsv; if (!isatty(0)) { close(0); open("/dev/tty", 0); @@ -1647,8 +1648,9 @@ void execute(char *filename, char *cmd, ...) va_end(argp); execvp(cmd, args); + errsv = errno; putserr(_("exec failed\n")); - exit(EXIT_FAILURE); + exit(errsv == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED); } if (id > 0) { signal(SIGINT, SIG_IGN); diff --git a/text-utils/pg.c b/text-utils/pg.c index ed9eb415a..f441c04f0 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -1380,9 +1380,8 @@ static void pgfile(FILE *f, const char *name) my_sigset(SIGTERM, oldterm); execl(sh, sh, "-c", cmd.cmdline + 1, NULL); - warn(_("failed to execute %s"), sh); - _exit(0177); - /* NOTREACHED */ + errexec(sh); + break; } case -1: mesg(_("fork() failed, " |