Return proper exit code when exec*() functions fail
authorJindrich Novy <jnovy@redhat.com>
Tue, 4 Nov 2008 09:09:31 +0000 (10:09 +0100)
committerJindrich Novy <jnovy@redhat.com>
Tue, 4 Nov 2008 09:09:31 +0000 (10:09 +0100)
- the correct exit code should be 127 accoring to bash(1),
  we want to keep the same exit code behaviour as bash for rpm

build/build.c
lib/psm.c
rpmio/url.c

index a3454db..f78c9fc 100644 (file)
@@ -187,7 +187,7 @@ fprintf(stderr, "*** rootDir %s buildDir %s\n", rootDir, buildDir);
        rpmlog(RPMLOG_ERR, _("Exec of %s failed (%s): %s\n"),
                scriptName, name, strerror(errno));
 
-       _exit(-1);
+       _exit(127); /* exit 127 for compatibility with bash(1) */
     }
 
     pid = waitpid(child, &status, 0);
index 1ddfa94..b79ecb7 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -658,7 +658,7 @@ static void doScriptExec(rpmts ts, ARGV_const_t argv, rpmtd prefixes,
            xx = execv(argv[0], argv);
        }
     }
-    _exit(-1);
+    _exit(127); /* exit 127 for compatibility with bash(1) */
 }
 
 /**
index f537518..fc069f4 100644 (file)
@@ -268,7 +268,7 @@ int urlGetFile(const char * url, const char * dest)
         ARGV_t argv = NULL;
         argvSplit(&argv, cmd, " ");
         execvp(argv[0], argv);
-        exit(-1); /* error out if exec fails */
+        exit(127); /* exit with 127 for compatibility with bash(1) */
     }
     wait = waitpid(pid, &rc, 0);
     cmd = _free(cmd);