Wow, I remember wall, from back when I was in short trousers. A look at the source for write(1) sent me to man utmp, which teacheth:
xterm(1) and other terminal emulators directly create a USER_PROCESS record and generate the ut_id by using
the string that suffix part of the terminal name (the characters following /dev/[pt]ty). If they find a
DEAD_PROCESS for this ID, they recycle it, otherwise they create a new entry. If they can, they will mark it
as DEAD_PROCESS on exiting and it is advised that they null ut_line, ut_time, ut_user, and ut_host as well.
pututxline looks to be the call we should make.
...
But of course it's more complicated than that, so I've committed something only half-baked:
native/all/pty/terminator_terminal_PtyProcess.cpp:
src/terminator/terminal/PtyProcess.java: Code to register the starting of a terminal, and its demise, with the utmpx facility, for wall(1), write(1) etc, at the suggestion of Aryeh Leib Taurog. This will probably erect a portability obstacle and will cause log spam because it doesn't work out of the box even for me on Linux. A regular user doesn't seem to have write permission to /var/run/utmp. sudo adduser <user> utmp works. Running terminator as root works. Neither of these seem like they're likely to be good ideas. How do other programs do this? xterm seems to use a setgid root utempter executable from a libutempter0 package. gnome-terminal doesn't directly do that but maybe it asks DBus or some such.