The switch controls message write time out to terminals. Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- term-utils/Makefile.am | 2 +- term-utils/wall.1 | 5 +++++ term-utils/wall.c | 13 +++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/term-utils/Makefile.am b/term-utils/Makefile.am index f0509f8..c40d9db 100644 --- a/term-utils/Makefile.am +++ b/term-utils/Makefile.am @@ -53,7 +53,7 @@ endif if BUILD_WALL usrbin_exec_PROGRAMS += wall -wall_SOURCES = wall.c ttymsg.c ttymsg.h +wall_SOURCES = wall.c ttymsg.c ttymsg.h $(top_srcdir)/lib/strutils.c dist_man_MANS += wall.1 if USE_TTY_GROUP diff --git a/term-utils/wall.1 b/term-utils/wall.1 index dbc7105..b3b2aa5 100644 --- a/term-utils/wall.1 +++ b/term-utils/wall.1 @@ -42,6 +42,7 @@ .Sh SYNOPSIS .Nm wall .Op Ar -n +.Op Ar -t TIMEOUT .Op Ar file .Sh DESCRIPTION .Nm Wall @@ -64,6 +65,10 @@ and the program is suid or sgid. .Bl -tag -width Fl .It Fl n, Fl Fl nobanner Supress banner +.It Fl t, Fl Fl timeout Ar TIMEOUT +Write timeout to terminals in seconds. Argument must be positive +integer. Default value is 300 seconds, which is a legacy from +time when people ran terminals over modem lines. .It Fl V, Fl Fl version Output version and exit. .It Fl h, Fl Fl help diff --git a/term-utils/wall.c b/term-utils/wall.c index 5782c5c..b8d7dfa 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(); -- 1.7.4.3 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html