Another somewhat associated problem is what a program like babysit
should do for authentication. Here is how babysit works (right out
of the man pages):
The first thing babysit does is fork and set the process
group of the child to its process id. This is so that any
child processes of the job will also be affected by signals.
The child then execs the program and runs. The parent wakes
up every ten seconds to see if a user has logged in. If so,
it signals the child process group to stop, and notifies the
console user of the suspended background job.
The parent then wakes up once a minute to see when the con-
sole user logs off, then signals the child process group to
resume, and waits again for another console user to log in.
This continues until the process is done.
A kill signal sent to the babysit process will cause the
child processes to be killed.
babysit does some extra checks to make sure the program does
not get hung unnecessarily. If /dev/console is owned by
someone, but there is no tty belonging to that user after
three minutes, then the program will be restarted. This
check is performed once every half hour that the program is
stopped.