aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/mesg
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-05-06 04:33:04 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-05-06 04:33:04 +0000
commit17b3efd432332b0ed3317496813bec51c0cc106c (patch)
tree9afc5ae665ac4d9aa52d78234d6183202b427d49 /usr.bin/mesg
parentb23de8a35253d927f47e1a31d6f883d2ee715311 (diff)
downloadsrc-17b3efd432332b0ed3317496813bec51c0cc106c.tar.gz
src-17b3efd432332b0ed3317496813bec51c0cc106c.zip
Notes
Diffstat (limited to 'usr.bin/mesg')
-rw-r--r--usr.bin/mesg/mesg.129
-rw-r--r--usr.bin/mesg/mesg.c16
2 files changed, 28 insertions, 17 deletions
diff --git a/usr.bin/mesg/mesg.1 b/usr.bin/mesg/mesg.1
index 77a29a15a005..c9f6800a21eb 100644
--- a/usr.bin/mesg/mesg.1
+++ b/usr.bin/mesg/mesg.1
@@ -32,7 +32,7 @@
.\" @(#)mesg.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd June 6, 1993
+.Dd May 5, 2002
.Dt MESG 1
.Os
.Sh NAME
@@ -44,15 +44,17 @@
.Sh DESCRIPTION
The
.Nm
-utility is invoked by a users to control write access others
-have to the terminal device associated with the standard error
-output.
+utility is invoked by a user to control write access others
+have to a terminal device.
Write access is allowed by default, and programs such as
.Xr talk 1
and
.Xr write 1
may display messages on the terminal.
.Pp
+The first terminal device in the sequence of devices associated with standard
+input, standard output and standard error is affected.
+.Pp
Options available:
.Bl -tag -width flag
.It Cm n
@@ -63,8 +65,8 @@ Permits messages to be displayed.
.Pp
If no arguments are given,
.Nm
-displays the present message status to the standard error output.
-.Pp
+displays the present message status to the standard output.
+.Sh DIAGNOSTICS
The
.Nm
utility exits with one of the following values:
@@ -77,15 +79,22 @@ Messages are not allowed.
.It Li ">1"
An error has occurred.
.El
-.Sh FILES
-.Bl -tag -width /dev/[pt]ty[pq]? -compact
-.It Pa /dev/[pt]ty[pq]?
-.El
+.Sh COMPATIBILITY
+Previous versions of the
+.Nm
+utility wrote the message status to the standard error output and
+affected the terminal attached to standard error without first trying the
+standard input or output devices.
.Sh SEE ALSO
.Xr biff 1 ,
.Xr talk 1 ,
.Xr wall 1 ,
.Xr write 1
+.Sh STANDARDS
+The
+.Nm
+utility conforms to
+.St -p1003.1-2001 .
.Sh HISTORY
A
.Nm
diff --git a/usr.bin/mesg/mesg.c b/usr.bin/mesg/mesg.c
index d80acb6c9ef6..dcd14c39e3af 100644
--- a/usr.bin/mesg/mesg.c
+++ b/usr.bin/mesg/mesg.c
@@ -79,28 +79,30 @@ main(argc, argv)
argc -= optind;
argv += optind;
- if ((tty = ttyname(STDERR_FILENO)) == NULL)
- err(1, "ttyname");
+ if ((tty = ttyname(STDIN_FILENO)) == NULL &&
+ (tty = ttyname(STDOUT_FILENO)) == NULL &&
+ (tty = ttyname(STDERR_FILENO)) == NULL)
+ err(2, "ttyname");
if (stat(tty, &sb) < 0)
- err(1, "%s", tty);
+ err(2, "%s", tty);
if (*argv == NULL) {
if (sb.st_mode & S_IWGRP) {
- (void)fprintf(stderr, "is y\n");
+ (void)puts("is y");
exit(0);
}
- (void)fprintf(stderr, "is n\n");
+ (void)puts("is n");
exit(1);
}
switch (*argv[0]) {
case 'y':
if (chmod(tty, sb.st_mode | S_IWGRP) < 0)
- err(1, "%s", tty);
+ err(2, "%s", tty);
exit(0);
case 'n':
if (chmod(tty, sb.st_mode & ~S_IWGRP) < 0)
- err(1, "%s", tty);
+ err(2, "%s", tty);
exit(1);
}