We redirect stderr to NULL since POSIX says it may be used (no modern shell
seems to be using it).
If more than 1 program is checked for availability, we use a function.
Emacs snippet make it uniform.
Error message is output on stderr and is always the same.
It is hard to keep track of all user sessions, since one may login through X
directly, without ever using a TTY. It seems like there is no standard way to
check for the number of running sessions. We could use files to track it but
then we run into race conditions.
For the sake of simplicity, and since running multiple sessions on the same
machine does not occur very often anyway, it is simpler to use one agent per
session (only 3 lines of code).