Re: BUG: NTPL: waitpid() doesn't return?

From: Matthias Urlichs (smurf_at_smurf.noris.de)
Date: 01/31/04

  • Next message: Tony Lindgren: "[PATCH] powernow-k8 max speed sanity check"
    Date:	Sat, 31 Jan 2004 21:00:50 +0100
    To: Linus Torvalds <torvalds@osdl.org>
    
    

    Hi,

    Linus Torvalds:
    >
    > "Clearly" is not correct. What I bet happens is:
    >
    > > 31346 execve("/usr/bin/apt-ftparchive", ["apt-ftparchive", "packages", "testing/all"], [/* 12 vars */] <unfinished ...>
    > > 31346 <... execve resumed> ) = 0
    > > 31346 exit_group(0) = ?
    > > 31340 --- SIGCHLD (Child exited) @ 0 (0) ---
    > > 31342 waitpid(31346, <unfinished ...>
    >
    > Notice how you do "waitpid()" for a _specific_ thread when you get a
    > SIGCHLD.
    >
    > How the heck do you know _which_ thread it was that exited?

    Please look again. The above trace clearly shows that #31346 has
    exited, which is exactly the thread being waitpid()ed for.

    What the program does is basically
    - spawn four threads or so
    - each thread forks off some process, and then waitpid()s for exactly
      that pid

    ... and all but the last waitpid() never returns even though all four
    child processes have exit_group()ed.

    > Rule: never EVER wait for a specific thread in a SIGCHLD handler. When you
    > get a SIGCHLD, your signal handler should just wait for "any thread".

    No SIGCHLD has been installed. (I checked the strace output.)

    -- 
    Matthias Urlichs     |     noris network AG     |     http://smurf.noris.de/
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Tony Lindgren: "[PATCH] powernow-k8 max speed sanity check"

    Relevant Pages

    • Re: 2.6.14-rc1 wait()/SIG_CHILD bevahiour
      ... On Mon, 19 Sep 2005, Badari Pulavarty wrote: ... I don't think it is SIGCHLD, because you can "strace" the waiter in one ... window, and send it a SIGCHLD _by_hand_ in the other window, and it will ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] Staircase scheduler v7.4
      ... > I don't know what the file wchan is good for, ... I bet the process is waiting for a SIGCHLD from a previously forked ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: PROBLEM: Failure to deliver SIGCHLD
      ... The server employs a very simple SIGCHLD handler that loops on ... until all zombie processes have been collected. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: is killing zombies possible w/o a reboot?
      ... >>could try sending a SIGCHLD to the parent and see if it does something ... It won't hurt init, but some processes do use the SIGCHLD to trigger a ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)