Forking from thread

This is a discussion on Forking from thread within the Linux Programming forums, part of the Platform Specific Boards category; is it good to make fork call from thread? how to handle termination of child forked by the thread?...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Location
    India, Gujarat
    Posts
    22

    Forking from thread

    is it good to make fork call from thread? how to handle termination of child forked by the thread?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The new process will have only one thread, a copy of the one that did fork in itself. All other threads won't exist in the new process.

    I have no idea what you mean by "termination of child forked by the thread" - it will send the same SIG_CHILD signal, and wait/wait_pid() etc will work just like in any other situation.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    > The new process will have only one thread, a copy of the one that did fork in itself.
    I thought this was wrong (from memory), but then I found this.
    http://docsun.cites.uiuc.edu/sun_doc...html#GEN-12013

    Fuzzy memory from my Solaris hacking days
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 04:34 AM
  2. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 03:55 PM
  3. Win32 Thread Object Model Revisted
    By Codeplug in forum Windows Programming
    Replies: 5
    Last Post: 12-15-2004, 07:50 AM
  4. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 10:34 PM
  5. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21