change signal disposition of already running process (SIGHUP)
Let's say I started Linux process, in the background. It is not a daemon, just a utility. If it gets SIGHUP开发者_C百科, it would be killed.
I did not take the "nohup" precaution. It is taking already much longer time than I thought.
After 4 hours of running, ssh session might get disconnected. But I don't want to lose the process. I want to prevent it being killed by SIGHUP.Is it possible to make the equivalent of
signal(SIGHUP, SIG_IGN);
to this process without restarting it ?
Thanks
Use disown(1)
disown: disown [-h] [-ar] [jobspec ...] Remove jobs from current shell.
Removes each JOBSPEC argument from the table of active jobs. Without any JOBSPECs, the shell uses its notion of the current job. Options: -a remove all jobs if JOBSPEC is not supplied -h mark each JOBSPEC so that SIGHUP is not sent to the job if the shell receives a SIGHUP -r remove only running jobs
Detaching a process from terminal, entirely
"disown" is a bash builtin that removes a shell job from the shell's job list. What this basically means is that you can't use "fg", "bg" on it anymore, but more importantly, when you close your shell it won't hang or send a SIGHUP to that child anymore. Unlike "nohup", "disown" is used after the process has been launched and backgrounded.
Diswon is the good solution for this time. For the future, a nice workaround is to use "screen" tool : if ever your ssh session disconnects, you can reconnect and refetch your still running screen.
However, I don't know a way to pull a current process into a screen session, so it won't solve your current case.
精彩评论