[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sat, 4 Oct 2003 17:36:28 -0600
Andreas Schwab wrote:
> JGraham <address@hidden> writes:
> > Come one, tell me you've never run a process that needed to run, then
> > realized that you had to log off?
> You don't need nohup for that. Background processes will just continue
> running after logout.
Hmm... Won't the background process still be running attached to the
existing tty and prevent new processes from using it as the new
login's controlling terminal?
I used to have serious problems with one vendor's license daemon. If
it were launched, backgrounded, and then user logged out of the
terminal then that pty could never be logged into again because the
system's login program would be unable to acquire the pty as a
controlling terminal since another process was running on that pty and
the login program was not smart enough to try another pty after that.
Specifically it would fail trying to set echo off for the password
entry and die then.
That could make it tricky to log into the machine if the pty you got
was the wedged one. You needed two windows. The first to start a
login you knew would not work and the second to get the next pty after
the stuck one and really log in. Yuck. I wrote a program to do the
detach and daemonize steps and then lauch another program specifically
for that program to avoid those troubles. Nowadays you would do that
with a one line perly. Something like this.
perl -MPOSIX -e '$pid=fork;exit if $pid;POSIX::setsid();exec shift, @ARGV'
There is a subtle difference between systems that implement job
control and those that don't regarding controlling terminals and it
has been a while since I have thought about the problems there. But I
think with job control shells it is not enough just to background the
task and log off. I think you really want to detach the process from
the controlling terminal first.