summaryrefslogtreecommitdiffstats
path: root/term-utils/wall.c
diff options
context:
space:
mode:
authorSami Kerola2011-04-06 21:31:04 +0200
committerKarel Zak2011-04-12 11:31:21 +0200
commitcae7485e59299c4b70ea7e1c7a4206df416701dc (patch)
tree8c94421e821721117dd2985c358e4566da0bc88a /term-utils/wall.c
parentwall: add long options and 79 char cut info to the man page (diff)
downloadkernel-qcow2-util-linux-cae7485e59299c4b70ea7e1c7a4206df416701dc.tar.gz
kernel-qcow2-util-linux-cae7485e59299c4b70ea7e1c7a4206df416701dc.tar.xz
kernel-qcow2-util-linux-cae7485e59299c4b70ea7e1c7a4206df416701dc.zip
wall: support --timeout switch
The switch controls message write time out to terminals. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'term-utils/wall.c')
-rw-r--r--term-utils/wall.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/term-utils/wall.c b/term-utils/wall.c
index eb47db375..d7f7178d7 100644
--- a/term-utils/wall.c
+++ b/term-utils/wall.c
@@ -68,6 +68,7 @@
#include "c.h"
#define IGNOREUSER "sleeper"
+#define WRITE_TIME_OUT 300 /* in seconds */
#ifndef MAXHOSTNAMELEN
# ifdef HOST_NAME_MAX
@@ -88,6 +89,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fprintf(out, _(
"\nOptions:\n"
" -n, --nobanner do not print banner, works only for root\n"
+ " -t, --timeout TIMEOUT write timeout in seconds\n"
" -V, --version output version information and exit\n"
" -h, --help display this help and exit\n\n"));
@@ -105,6 +107,7 @@ main(int argc, char **argv) {
int print_banner = TRUE;
char *mbuf;
size_t mbufsize;
+ long timeout = WRITE_TIME_OUT;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -112,12 +115,13 @@ main(int argc, char **argv) {
static const struct option longopts[] = {
{ "nobanner", no_argument, 0, 'n' },
+ { "timeout", required_argument, 0, 't' },
{ "version", no_argument, 0, 'V' },
{ "help", no_argument, 0, 'h' },
{ NULL, 0, 0, 0 }
};
- while ((ch = getopt_long(argc, argv, "nVh", longopts, NULL)) != -1) {
+ while ((ch = getopt_long(argc, argv, "nt:Vh", longopts, NULL)) != -1) {
switch (ch) {
case 'n':
if (geteuid() == 0)
@@ -125,6 +129,11 @@ main(int argc, char **argv) {
else
warnx(_("--nobanner is available only for root"));
break;
+ case 't':
+ timeout = strtoll_or_err(optarg, _("invalid timeout argument"));
+ if (timeout < 1)
+ errx(EXIT_FAILURE, _("invalid timeout argument: %s"), optarg);
+ break;
case 'V':
printf(_("%s from %s\n"), program_invocation_short_name,
PACKAGE_STRING);
@@ -161,7 +170,7 @@ main(int argc, char **argv) {
continue;
xstrncpy(line, utmpptr->ut_line, sizeof(utmpptr->ut_line));
- if ((p = ttymsg(&iov, 1, line, 60*5)) != NULL)
+ if ((p = ttymsg(&iov, 1, line, timeout)) != NULL)
warnx("%s", p);
}
endutent();