[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: NOHUP



Oommen Thomas wrote:

> glynn> > Why then does background processes not get killed at all, when user logs
> glynn> > out ? This happens with even simple shell scripts - say I have one with
> glynn> > 'tail -f /etc/passwd' which if run in background, remains (sleeping)
> glynn> > unatttached even after logging out. 
> glynn> 
> glynn> SIGHUP is only sent to the foreground process group.
> 
> So, how to solve this problem?
> ie. To get all background processes to terminate by default, when the user
> logs out. Only when a 'nohup' is specified, must the process continue
> unattached.

You could run something like the following from ~/.bash_logout:

	i=1 ; while [ $i -lt 100 ] ; do kill %$i ; i=$((i+1)) ; done

-- 
Glynn Clements <glynn@xxxxxxxxxxxx>


------------------------------