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

[Q] what to do when waitpid() returns ECHILD under signal(SIGCHLD, SIG_IGN)?

From
Junio C Hamano <junkio@cox.net>
Date
Jun 19, 2006, 23:49 UTC
Message-ID
<7vwtbc7ll6.fsf@assigned-by-dhcp.cox.net>

Somebody I met last week in Japan reported that the socks client he uses to cross the firewall to connect to git:// port from his company environment seems to do signal(SIGCHLD, SIG_IGN) before spawning git. When "git clone" is invoked this way, we get a mysterious failure.

I can reproduce the problem without using funny socks client like this:

        : gitster; trap '' SIGCHLD
        : gitster; git clone git://git.kernel.org/pub/scm/git/git.git/ foo.git
        error: waitpid failed (No child processes)
        fetch-pack from 'git://git.kernel.org/pub/scm/git/git.git/' failed.
        : gitster; ls foo.git
        ls: foo.git: No such file or directory

We could work this around by having signal(SIGCHLD, SIG_DFL) upfront in git.c::main(), but I am wondering what the standard practice for programs that use waitpid() call. Do they protect themselves from this in order to reliably obtain child exit status? Or do they simply consider it is a user error to run a program that use waitpid() with SIGCHLD ignored?

http://www.opengroup.org/onlinepubs/009695399/functions/waitpid.html

explicitly says this is an expected behaviour, so barfing upon ECHILD sounds like a bug on our part.

Next: Linus Torvalds
Message 1 of 7 in “[Q] what to do when waitpid() returns ECHILD under signal(SIGCHLD, SIG_IGN)?”
  1. Junio C HamanoJun 19, 2006
  2. Linus TorvaldsJun 19, 2006
  3. Junio C HamanoJun 20, 2006
  4. Linus TorvaldsJun 20, 2006
  5. Restore SIGCHLD to SIG_DFL where we care about waitpid().Junio C Hamano, Jun 20, 2006
  6. Petr BaudisJun 20, 2006
  7. Edgar ToernigJun 20, 2006

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.