4

I'm curious about the behavior of broadcast messages by

$ sudo wall myfile

the message from myfile appears on all /dev/ttyN devices (the ones to which I can switch by pressing Ctrl+Alt+fN), it also appears on the xterm windows I have opened, but it doesn't appear on gnome-terminal (actually I use Linux Mint with MATE, so it's mate-terminal, but it is fork of gnome-terminal).

There's also interesting note if I run tmux in the xterm: I expected that the message would appear on all terminal sessions that are running in tmux (on all windows, and in each pane of each window), but actually the message appears just at current cursor position in the xterm window.

If I check current controlling terminal by calling tty, it reports different terminals for different windows in tmux: say, I have /dev/pts/11 in one tmux window and /dev/pts/12 in another one. But, broadcast message appears just once for each xterm window, not for each terminal session opened in tmux.

It seems to me that terminal emulator, when allocating pseudo-terminal, needs, like, "registering" it somewhere to make it able to receive broadcast messages, and so, xterm does it, but mate-terminal and tmux does not. But it sounds weird since pseudo-terminal is allocated by the kernel, so, it should be "registered" automatically everywhere it needs to be.

I'd be glad if someone explain how does it work and why the behavior is that (seemingly weird).

  • No reproducible. – Braiam Aug 17 '14 at 21:22
  • @Braiam, even with tmux? That is, if you run tmux session with several windows and/or panes, your broadcast message appears in each window/pane? – Dmitry Frank Aug 17 '14 at 21:49
  • I have the same problem, however here it works with gnome-terminal, but not with urxvt. – fiatjaf Apr 20 '16 at 14:32
  • does gnome-terminal turn off mesg ? – Jeff Schaller Apr 20 '16 at 14:39
  • mesg "is y" both on gnome-terminal and urxvt here. – fiatjaf Apr 20 '16 at 15:39
2

The terminals listed hints that the behavior is seen with Linux: The clues are in the manual page for wall (Solaris for instance is different):

wall displays a message, or the contents of a file, or otherwise its standard input, on the terminals of all currently logged in users.

Some sessions, such as wdm, that have in the beginning of utmp(5) ut_type data a ':' character will not get the message from wall. This is done to avoid write errors.

That is, wall uses the utmp data, looks for terminals in use (i.e., logged-in users), and writes to the associated device. Each line in the output of w shows a (possible) terminal, recorded by the terminal in the utmp file. For instance, I am ssh'd into a server and running screen while at the same time I logged into a console. Just for completeness, I ran xterm using the -ls (login-shell) option. Here is the output of w:

$ w
 19:53:15 up  4:08,  5 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
tom      tty2                      19:48    5:11   0.04s  0.02s -tcsh
tom      pts/0    michener:S.0     15:51   13:18   0.35s  0.24s ssh -X thomas@b
tom      pts/2    michener:S.1     16:34    2.00s  0.14s  0.00s sh -c w
tom      pts/4    michener:S.3     15:52    3:59m  0.12s  0.00s /bin/sh /users/
tom      pts/3    localhost:10.0   19:53    7.00s  0.03s  0.03s -tcsh

and running wall writes to each of those TTY devices.

However, if the terminal does not write to the utmp file, it will not be listed — and wall will ignore it.

Now, some programs may have the feature compiled-in, but lack privileges to change it. That is why some programs are run with setgid to the "utmp" group. Other programs (such as xterm — or gnome-terminal) may use an external program that updates utmp on their behalf.

With gnome-terminal, the feature has been deprecated due to the mindset of the gnome developers that (a) users run on a local machine, where gdm handles login, and (b) consequently there's no distinction worth bothering about between login shells and non-login shells. That makes for some interesting bug reports:

1

On urxvt, you have to issue

chown root.utmp /usr/bin/urxvt
chmod g+s /usr/bin/urxvt

Then it starts working.

I don't understand why, just copied (and tested) from http://permalink.gmane.org/gmane.comp.terminal-emulators.rxvt-unicode.general/1484.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.