]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
text-utils: use errexec()
authorKarel Zak <kzak@redhat.com>
Thu, 1 Feb 2018 14:40:43 +0000 (15:40 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 1 Feb 2018 14:40:43 +0000 (15:40 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/more.c
text-utils/pg.c

index cbff39b11301ef4866b6c33994af69f4e941e692..0b2db22f395b58865bb55fcfec03859597c6563f 100644 (file)
@@ -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);
index ed9eb415af69cf1ad67f4d1da28dd02a719840b4..f441c04f012e1a3026cb0dc29eacaaae125d3976 100644 (file)
@@ -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, "