hi,
It seems that when I logout from the console, the background process doesn't get HUP signal: { trap "echo Ignore HUP >>/tmp/trap.out" 1; while sleep 3;do echo hello >>/tmp/hello.txt;done; }& And it seems it will become a daemon and run forever until rebooting. Is this correct? Why it didn't get HUP signal?
Thanks!
On 12/29/2008 10:05 AM, 平天韩 wrote:
hi,
It seems that when I logout from the console, the background process doesn't get HUP signal: { trap "echo Ignore HUP >>/tmp/trap.out" 1; while sleep 3;do echo hello >>/tmp/hello.txt;done; }& And it seems it will become a daemon and run forever until rebooting. Is this correct? Why it didn't get HUP signal?
Thanks!
Are you running this from a terminal window? Are you possibly setting nohup in your environment. Are you typing the above commands directly? What happens if you place these into a script and run the script in the background?
There are a number of things that can cause a shell script to ignore the HUP signal. I tested this as a script on an Ubuntu laptop, and it behaved the same as yours:
The process remained. So the issue is not that exiting the parent process (GNOME Term) or logging out of GNOME fails to issue a HUP, it is that the process itself ignores the HUP signal since I sent a "kill -HUP <pid>" to the process.
If you simply send the HUP signal, you will see that "Ignore HUP" will appear in /tmp/trap.out".
The signal(1) command is probably the culprit, though the man pages are vague.
2008/12/30, Jerry Feldman gaf@blu.org:
On 12/29/2008 10:05 AM, 平天韩 wrote:
hi,
It seems that when I logout from the console, the background process doesn't get HUP signal: { trap "echo Ignore HUP >>/tmp/trap.out" 1; while sleep 3;do echo hello >>/tmp/hello.txt;done; }& And it seems it will become a daemon and run forever until rebooting. Is this correct? Why it didn't get HUP signal?
Thanks!
Are you running this from a terminal window?
I am running this in tty2, a console. I just type those into the console and run it, then logout.
Are you possibly setting nohup in your environment.
It seems it is. But how?
Are you typing the above commands directly? What happens if you place these into a script and run the script in the background?
There are a number of things that can cause a shell script to ignore the HUP signal. I tested this as a script on an Ubuntu laptop, and it behaved the same as yours:
The process remained. So the issue is not that exiting the parent process (GNOME Term) or logging out of GNOME fails to issue a HUP, it is that the process itself ignores the HUP signal since I sent a "kill -HUP <pid>" to the process.
If you simply send the HUP signal, you will see that "Ignore HUP" will appear in /tmp/trap.out".
I have the same results with you.
The signal(1) command is probably the culprit, though the man pages are vague.
I suspect of that maybe the logout doesn't send out HUP to these background processes?
-- Jerry Feldman gaf@blu.org Boston Linux and Unix PGP key id: 537C5846 PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB CA3B 4607 4319 537C 5846
On 12/29/2008 04:56 PM, 平天韩 wrote:
2008/12/30, Jerry Feldman gaf@blu.org:
On 12/29/2008 10:05 AM, 平天韩 wrote:
hi,
It seems that when I logout from the console, the background process doesn't get HUP signal: { trap "echo Ignore HUP >>/tmp/trap.out" 1; while sleep 3;do echo hello >>/tmp/hello.txt;done; }& And it seems it will become a daemon and run forever until rebooting. Is this correct? Why it didn't get HUP signal?
Thanks!
Are you running this from a terminal window?
I am running this in tty2, a console. I just type those into the console and run it, then logout.
Are you possibly setting nohup in your environment.
It seems it is. But how?
Are you typing the above commands directly? What happens if you place these into a script and run the script in the background?
There are a number of things that can cause a shell script to ignore the HUP signal. I tested this as a script on an Ubuntu laptop, and it behaved the same as yours:
The process remained. So the issue is not that exiting the parent process (GNOME Term) or logging out of GNOME fails to issue a HUP, it is that the process itself ignores the HUP signal since I sent a "kill -HUP <pid>" to the process.
If you simply send the HUP signal, you will see that "Ignore HUP" will appear in /tmp/trap.out".
I have the same results with you.
The signal(1) command is probably the culprit, though the man pages are vague.
I suspect of that maybe the logout doesn't send out HUP to these background processes?
After looking at this again now that I understand the specific issue. I would agree.
Jerry Feldman wrote:
On 12/29/2008 04:56 PM, ƽÌ캫 wrote:
2008/12/30, Jerry Feldman gaf@blu.org:
On 12/29/2008 10:05 AM, ƽÌ캫 wrote:
hi,
It seems that when I logout from the console, the background process doesn't get HUP signal: { trap "echo Ignore HUP >>/tmp/trap.out" 1; while sleep 3;do echo hello >>/tmp/hello.txt;done; }& And it seems it will become a daemon and run forever until rebooting. Is this correct? Why it didn't get HUP signal?
Thanks!
Are you running this from a terminal window?
I am running this in tty2, a console. I just type those into the console and run it, then logout.
Are you possibly setting nohup in your environment.
It seems it is. But how?
Are you typing the above commands directly? What happens if you place these into a script and run the script in the background?
There are a number of things that can cause a shell script to ignore the HUP signal. I tested this as a script on an Ubuntu laptop, and it behaved the same as yours:
The process remained. So the issue is not that exiting the parent process (GNOME Term) or logging out of GNOME fails to issue a HUP, it is that the process itself ignores the HUP signal since I sent a "kill -HUP <pid>" to the process.
If you simply send the HUP signal, you will see that "Ignore HUP" will appear in /tmp/trap.out".
I have the same results with you.
The signal(1) command is probably the culprit, though the man pages are vague.
I suspect of that maybe the logout doesn't send out HUP to these background processes?
After looking at this again now that I understand the specific issue. I would agree.
By default, the "huponexit" option is NOT set on bash shells, so a terminating interactive shell does NOT send HUPs to background processes.
Try it again, but run "shopt -s huponexit" before executing the background process. When you log out, HUPs should be sent to child processes. ---------------------------------------------------------------------- - Rick Stevens, Systems Engineer ricks@nerd.com - - AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 - - - - Do not taunt the sysadmins, for they are subtle and quick to anger - ----------------------------------------------------------------------
2008/12/30, Rick Stevens ricks@nerd.com:
Jerry Feldman wrote:
On 12/29/2008 04:56 PM, ƽÌ캫 wrote:
2008/12/30, Jerry Feldman gaf@blu.org:
On 12/29/2008 10:05 AM, ƽÌ캫 wrote:
hi,
It seems that when I logout from the console, the background process doesn't get HUP signal: { trap "echo Ignore HUP >>/tmp/trap.out" 1; while sleep 3;do echo hello >>/tmp/hello.txt;done; }& And it seems it will become a daemon and run forever until rebooting. Is this correct? Why it didn't get HUP signal?
Thanks!
Are you running this from a terminal window?
I am running this in tty2, a console. I just type those into the console and run it, then logout.
Are you possibly setting nohup in your environment.
It seems it is. But how?
Are you typing the above commands directly? What happens if you place these into a script and run the script in the background?
There are a number of things that can cause a shell script to ignore the HUP signal. I tested this as a script on an Ubuntu laptop, and it behaved the same as yours:
The process remained. So the issue is not that exiting the parent process (GNOME Term) or logging out of GNOME fails to issue a HUP, it is that the process itself ignores the HUP signal since I sent a "kill -HUP <pid>" to the process.
If you simply send the HUP signal, you will see that "Ignore HUP" will appear in /tmp/trap.out".
I have the same results with you.
The signal(1) command is probably the culprit, though the man pages are vague.
I suspect of that maybe the logout doesn't send out HUP to these background processes?
After looking at this again now that I understand the specific issue. I would agree.
By default, the "huponexit" option is NOT set on bash shells, so a terminating interactive shell does NOT send HUPs to background processes.
Thank you very much for pointing this out.
Try it again, but run "shopt -s huponexit" before executing the background process. When you log out, HUPs should be sent to child processes.
Yes, I have seen the HUP signal being sent to the background process if set the "huponexit".
But even though i ignore HUP in the background process, it quits every time when logout, after echo a line of "Ignore HUP" to /tmp/trap.out. What's wrong?
- Rick Stevens, Systems Engineer ricks@nerd.com -
- AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 -
-- Do not taunt the sysadmins, for they are subtle and quick to anger -
-- fedora-list mailing list fedora-list@redhat.com To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
ƽÌ캫 wrote:
2008/12/30, Rick Stevens ricks@nerd.com:
Jerry Feldman wrote:
On 12/29/2008 04:56 PM, ƽÌ캫 wrote:
2008/12/30, Jerry Feldman gaf@blu.org:
On 12/29/2008 10:05 AM, ƽÌ캫 wrote:
hi,
It seems that when I logout from the console, the background process doesn't get HUP signal: { trap "echo Ignore HUP >>/tmp/trap.out" 1; while sleep 3;do echo hello >>/tmp/hello.txt;done; }& And it seems it will become a daemon and run forever until rebooting. Is this correct? Why it didn't get HUP signal?
Thanks!
Are you running this from a terminal window?
I am running this in tty2, a console. I just type those into the console and run it, then logout.
Are you possibly setting nohup in your environment.
It seems it is. But how?
Are you typing the above commands directly? What happens if you place these into a script and run the script in the background?
There are a number of things that can cause a shell script to ignore the HUP signal. I tested this as a script on an Ubuntu laptop, and it behaved the same as yours:
The process remained. So the issue is not that exiting the parent process (GNOME Term) or logging out of GNOME fails to issue a HUP, it is that the process itself ignores the HUP signal since I sent a "kill -HUP <pid>" to the process.
If you simply send the HUP signal, you will see that "Ignore HUP" will appear in /tmp/trap.out".
I have the same results with you.
The signal(1) command is probably the culprit, though the man pages are vague.
I suspect of that maybe the logout doesn't send out HUP to these background processes?
After looking at this again now that I understand the specific issue. I would agree.
By default, the "huponexit" option is NOT set on bash shells, so a terminating interactive shell does NOT send HUPs to background processes.
Thank you very much for pointing this out.
Try it again, but run "shopt -s huponexit" before executing the background process. When you log out, HUPs should be sent to child processes.
Yes, I have seen the HUP signal being sent to the background process if set the "huponexit".
But even though i ignore HUP in the background process, it quits every time when logout, after echo a line of "Ignore HUP" to /tmp/trap.out. What's wrong?
Because while a logout doesn't send a HUP unless huponexit is set, it DOES send a TERM signal which should terminate child processes. You need to trap that signal as well or use a "disown" on the PID of the child process to disassociate it from the login shell. ---------------------------------------------------------------------- - Rick Stevens, Systems Engineer ricks@nerd.com - - AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 - - - - "You think that's tough? Try herding cats!" - ----------------------------------------------------------------------
Because while a logout doesn't send a HUP unless huponexit is set, it DOES send a TERM signal which should terminate child processes. You
No. It seems if I didn't set huponexit, logout won't send either "HUP" or "TERM" to the background process. The process will keep running, like a daemon after the logout. But if I set the huponexit, logout will kill the background process with some other signals, they are not HUP or TERM.
If I sent HUP to the session leader of the control terminal (the bash I think, and it didn't set huponexit), the bash will quit. Before that, the bash will first send HUP to the background process and then send another signal other than TERM to kill it.
I think the "HUP" means the terminal maybe broken, so bash will signal each of its child to quit. But only logout it won't signal children.
need to trap that signal as well or use a "disown" on the PID of the child process to disassociate it from the login shell.
Thank you for pointing out the "disown".