summaryrefslogtreecommitdiffstats
path: root/login-utils
diff options
context:
space:
mode:
authorFrancesco Cosoleto2010-12-10 17:40:11 +0100
committerKarel Zak2010-12-10 21:13:44 +0100
commit5eae5930931742e80df9da51888842ae9be0eb33 (patch)
tree1a66df810b853d0087f169c36225b22ea053f5a9 /login-utils
parentdocs: update DEPRECATED file (diff)
downloadkernel-qcow2-util-linux-5eae5930931742e80df9da51888842ae9be0eb33.tar.gz
kernel-qcow2-util-linux-5eae5930931742e80df9da51888842ae9be0eb33.tar.xz
kernel-qcow2-util-linux-5eae5930931742e80df9da51888842ae9be0eb33.zip
mesg: change error exit code from 1 to >1
According to POSIX and mesg(1) error exit code should be >1. Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Diffstat (limited to 'login-utils')
-rw-r--r--login-utils/mesg.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/login-utils/mesg.c b/login-utils/mesg.c
index 46e6248e0..c24a10926 100644
--- a/login-utils/mesg.c
+++ b/login-utils/mesg.c
@@ -56,6 +56,12 @@
#include <sys/stat.h>
#include "nls.h"
+/* exit codes */
+
+#define IS_ALLOWED 0 /* Receiving messages is allowed. */
+#define IS_NOT_ALLOWED 1 /* Receiving messages is not allowed. */
+#define MESG_EXIT_FAILURE 2 /* An error occurred. */
+
int main(int argc, char *argv[])
{
struct stat sb;
@@ -77,18 +83,18 @@ int main(int argc, char *argv[])
argv += optind;
if ((tty = ttyname(STDERR_FILENO)) == NULL)
- err(EXIT_FAILURE, _("ttyname failed"));
+ err(MESG_EXIT_FAILURE, _("ttyname failed"));
if (stat(tty, &sb) < 0)
- err(EXIT_FAILURE, _("stat %s failed"), tty);
+ err(MESG_EXIT_FAILURE, _("stat %s failed"), tty);
if (!*argv) {
if (sb.st_mode & (S_IWGRP | S_IWOTH)) {
puts(_("is y"));
- return EXIT_SUCCESS;
+ return IS_ALLOWED;
}
puts(_("is n"));
- return EXIT_FAILURE;
+ return IS_NOT_ALLOWED;
}
switch (*argv[0]) {
@@ -98,15 +104,15 @@ int main(int argc, char *argv[])
#else
if (chmod(tty, sb.st_mode | S_IWGRP | S_IWOTH) < 0)
#endif
- err(EXIT_FAILURE, _("change %s mode failed"), tty);
- return EXIT_SUCCESS;
+ err(MESG_EXIT_FAILURE, _("change %s mode failed"), tty);
+ return IS_ALLOWED;
case 'n':
if (chmod(tty, sb.st_mode & ~(S_IWGRP|S_IWOTH)) < 0)
- err(EXIT_FAILURE, _("change %s mode failed"), tty);
- return EXIT_FAILURE;
+ err(MESG_EXIT_FAILURE, _("change %s mode failed"), tty);
+ return IS_NOT_ALLOWED;
}
usage:
fprintf(stderr, _("Usage: %s [y | n]"), program_invocation_short_name);
- return EXIT_FAILURE;
+ return MESG_EXIT_FAILURE;
}