git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Portability: returning void

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 29, 2011, 23:49 UTC
Message-ID
<20110329234955.GB14578@elie>
In-Reply-To
<20110329221652.GB23510@sigill.intra.peff.net>
Jeff King wrote:
Show 5 quoted lines
> The problem is that the sleeps hang around for 100 seconds, and they are
> connected to the test script's stdout. It works to run "./t0081-*"
> because bash sees the SIGCHLD and knows the script is done. But the
> prove program actually ignore the SIGCHLD and waits until stdout and
> stderr on the child are closed.

Strange. Why would prove tell its children to ignore SIGCHLD and SIGTERM?

> Double-weird is that if you "strace" the prove process, it will still
> hang. But if you "strace -f", it _won't_ hang.

Well, it hangs for me. :) The strangest aspect is that after 100 seconds, all is well again, which suggests that there's more happening than an unreaped process.

After lowering the sleep to 15 seconds:
| kill: 19422
| bash(19422)---sleep(19424)
|
| ok 3 - 0-length read, no input available
[...]
| kill: 19431
| bash(19431)---sleep(19434)
| ok 5 - 1-byte read, no input available
[...]
| kill: 19438
| bash(19438)---sleep(19441)
| 
| ok 6 - long read (around 8192 bytes)
[...]
| # passed all 13 test(s)
[...]
| 19398 18:31:12 exit_group(0)            = ?
| 19397 18:31:12 <... select resumed> )   = ? ERESTARTNOHAND (To be restarted)
| 19397 18:31:12 --- SIGCHLD (Child exited) @ 0 (0) ---
| 19397 18:31:12 select(8, [4 6], NULL, NULL, NULL <unfinished ...>

The test script exits, but "prove" is stuck in select and does not want to start reaping yet. So presumably the test script's children are adopted by init. We wait around 13 seconds, and then:

| 19424 18:31:25 <... nanosleep resumed> NULL) = 0
| 19424 18:31:25 close(1)                 = 0
| 19424 18:31:25 close(2)                 = 0
| 19424 18:31:25 exit_group(0)            = ?
| 19422 18:31:25 <... wait4 resumed> 0x7fff65d1ee6c, 0, NULL) = ? ERESTARTSYS (To be restarted)
| 19422 18:31:25 --- SIGTERM (Terminated) @ 0 (0) ---

The first sleep wakes up and dies. The corresponding subshell wakes up, reaps the child, and finally accepts SIGTERM.

| 19434 18:31:26 <... nanosleep resumed> NULL) = 0
[...]
| 19438 18:31:26 --- SIGTERM (Terminated) @ 0 (0) ---
Likewise for the second and third sleeps.
| 19397 18:31:26 <... select resumed> )   = 2 (in [4 6])
| 19397 18:31:26 read(4, "", 65536)       = 0
| 19397 18:31:26 read(6, "", 65536)       = 0
| 19397 18:31:26 wait4(19398, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19398
Now "prove" wakes up again.

The analagous experiment for dash, mksh, etc shows that their subshells exec()'d /bin/sleep so the SIGTERM reaches sleep right away with no trouble.

Previous: Jeff KingNext: Jeff King
Message 5 of 18 in “Portability: returning void”
  1. Portability: returning voidMichael Witten, Mar 29, 2011
  2. Jonathan NiederMar 29, 2011
  3. Jeff KingMar 29, 2011
  4. Jeff KingMar 29, 2011
  5. Jonathan NiederMar 29, 2011
  6. Jeff KingMar 30, 2011
  7. Jonathan NiederMar 30, 2011
  8. Jeff KingMar 30, 2011
  9. Jonathan NiederMar 30, 2011
  10. Jeff KingMar 30, 2011
  11. Johannes SixtMar 30, 2011
  12. tests: introduce helper to fill a pipe in the backgroundJonathan Nieder, Mar 30, 2011
  13. Jonathan NiederMar 30, 2011
  14. Jeff KingMar 30, 2011
  15. Jonathan NiederMar 30, 2011
  16. [PULL svn-fe] Re: Portability: returning voidJonathan Nieder, Mar 30, 2011
  17. Junio C HamanoMar 30, 2011
  18. Jonathan NiederMar 30, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.