summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-01-21 22:47:09 +0000
committerJim Meyering <jim@meyering.net>2004-01-21 22:47:09 +0000
commit918fbb381068a60473d85f1464876afa626e6603 (patch)
tree8f744de92f98b0f2e40c8aa173095e8537e0a762 /src
parent654e59cfd460936609bb2093156e3f3582d537c7 (diff)
downloadcoreutils-918fbb381068a60473d85f1464876afa626e6603.tar.xz
(usage): Use EXIT_SUCCESS, not 0, for clarity.
(CHROOT_FOUND_BUT_CANNOT_INVOKE, CHROOT_FAILURE): Remove. (main): Initialize exit_failure to EXIT_FAIL. (main): Exit with status 1 rather than 127 if chroot itself fails, as per documentation. (main): Use EXIT_ENOENT and EXIT_CANNOT_INVOKE rather than roll-your-own symbols or integers.
Diffstat (limited to 'src')
-rw-r--r--src/chroot.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/chroot.c b/src/chroot.c
index 9a2c913ee..5a28e32c4 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -31,23 +31,13 @@
#define AUTHORS "Roland McGrath"
-/* Exit statuses. */
-enum
- {
- /* found the specified command but failed to invoke it. */
- CHROOT_FOUND_BUT_CANNOT_INVOKE = 126,
-
- /* `chroot' itself failed, or did not find the specified command. */
- CHROOT_FAILURE = 127
- };
-
/* The name this program was run with, for error messages. */
char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -80,6 +70,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ initialize_exit_failure (EXIT_FAIL);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
@@ -87,15 +78,14 @@ main (int argc, char **argv)
if (argc <= 1)
{
error (0, 0, _("too few arguments"));
- usage (CHROOT_FAILURE);
+ usage (EXIT_FAIL);
}
if (chroot (argv[1]))
- error (CHROOT_FAILURE, errno,
- _("cannot change root directory to %s"), argv[1]);
+ error (EXIT_FAIL, errno, _("cannot change root directory to %s"), argv[1]);
if (chdir ("/"))
- error (CHROOT_FAILURE, errno, _("cannot chdir to root directory"));
+ error (EXIT_FAIL, errno, _("cannot chdir to root directory"));
if (argc == 2)
{
@@ -116,9 +106,7 @@ main (int argc, char **argv)
execvp (argv[0], argv);
{
- int exit_status = (errno == ENOENT
- ? CHROOT_FAILURE
- : CHROOT_FOUND_BUT_CANNOT_INVOKE);
+ int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
error (0, errno, _("cannot run command %s"), quote (argv[0]));
exit (exit_status);
}