0

When i write a shell script like below:

# demo.sh
somework &

Then run it sh demo.sh.Use & will cause the demo.sh exit and make the somework's parrent PID be 1, the init.

Then i exit my terminal, make the session over, why the somework doesn't receive the HUP, and jobs can't show it. So i guess it has been disown.

I write some code in ruby to test it:

# Fork an process then sleep it.
fork do 
  sleep
end

Then i run it with ruby demo.rb. With ps shown it parent process is init now.

Then i exit my terminal. It still running.

Why when a process become an orphan will disown it ?

1 Answers1

0

http://www.gnu.org/software/libc/manual/html_node/Orphaned-Process-Groups.html

Got my answer from GNU Manual:

To prevent problems, process groups that continue running even after the session leader has terminated are marked as orphaned process groups.