Re: is it possible to create an orphaned process?

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

 



On 05Sep2008 19:40, Konstantin Svist <fry.kun@xxxxxxxxx> wrote:
| I have an odd application that has threads which hang around until all
| child processes have finished executing.
| I'd like to create a background process that isn't a child of said
| thread, so that the thread can exit.

Fork twice when you make the children. The immediate child should exit.
The grandchild should exec your "child" process. Since its parent exited
(the imediate child) it becomes inherited by init. Your main process
will be fine.

However, I would dig a bit into why the threads hang around (if you
have the source, or can play with strace and lsof). Why? Because it is
possible for a process to have children unknowingly. Like this:

  sleep 3600 &          # makes "sleep" a child of the current process
  exec your-app ...     # now you app has "sleep" as a child

Provided you started the app itself as a child (no "exec") you're fine.
Just something to keep in mind.

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

There's no trick to being a humorist when you have the whole government
working for you.        - Will Rogers

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux