]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(main): Exit with status 126 or 127 when execvp or
authorJim Meyering <jim@meyering.net>
Thu, 1 Aug 2002 08:50:19 +0000 (08:50 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 1 Aug 2002 08:50:19 +0000 (08:50 +0000)
execv fails, for consistency with POSIX commands like env and nice.

src/chroot.c

index 7600875879fb6f239f5486cf0983f27768f7da13..4904c84d6d334d73c5539e55fbdbe428c2ea329f 100644 (file)
@@ -102,8 +102,10 @@ main (int argc, char **argv)
 
   /* Execute the given command.  */
   execvp (argv[0], argv);
-  error (1, errno, _("cannot execute %s"), argv[0]);
 
-  exit (1);
-  return 1;
+  {
+    int exit_status = (errno == ENOENT ? 127 : 126);
+    error (0, errno, "%s", argv[0]);
+    exit (exit_status);
+  }
 }