help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Command run in the background (with '&' at the end) stil


From: Clark WANG
Subject: Re: [Help-bash] Command run in the background (with '&' at the end) still runs even when the user exit from the login shell?
Date: Fri, 13 Dec 2013 11:51:46 +0800

On Fri, Dec 13, 2013 at 6:53 AM, Peng Yu <address@hidden> wrote:

> Hi,
>
> My previous impression was that processes run with '&' will be
> automatically terminated once the user logs out. But I just checked
> with the following example, it seems that these processes will
> continue to run until finished.
>
> From my understanding Bash would not explicitly kill the background jobs.
But it may send signals to them. For example, "If  the  huponexit  shell
option has been set with shopt, bash sends a SIGHUP to all jobs when an
interactive login shell exits." But it's up to the processes to decide how
to deal with the signals.


> Had bash ever terminated processes run with '&' before upon user
> logging out? Or there is some other shell that has this behavior?
> Thanks.
>
> /test/bash/man/operator/&$ cat infiniteloop.sh
> #!/usr/bin/env bash
>
> while true
> do
>   date > /tmp/infiniteloop.txt
>   sleep 1
> done
>
> /test/bash/man/operator/&$ ./infiniteloop.sh &
> [1] 28300
> /test/bash/man/operator/&$ exit
> logout
>
>
> /tmp$ cat infiniteloop.txt
> Thu Dec 12 16:52:00 CST 2013
> /tmp$ cat infiniteloop.txt
> Thu Dec 12 16:52:41 CST 2013
>
> --
> Regards,
> Peng
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]