pass errno from exec() to parent in spawn()
authorNicolas Edel <nicolas.edel@gmail.com>
Fri, 18 Nov 2011 10:49:22 +0000 (12:49 +0200)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 18 Nov 2011 11:50:36 +0000 (13:50 +0200)
commit6cfdd9e66519b513e0935c410fbb30fc880efb61
treedbb7f7b3d94266c462bde4b5ab41874e874d709c
parent9f1903c072936fb15f03f93182c57beb4621b39d
pass errno from exec() to parent in spawn()

  Open a pipe, set FD_CLOEXEC.

  Child: if exec() fails, grab errno and write it to pipe.

  Parent: try to read from the pipe -- if you get something, it means the
  child didn't exec and the reason is in the pipe. Wait for the child to exit
  and return -1 and set errno to whatever the child got.

  Also use _exit() instead of exit() when dying in the child after exec
  failure -- running exit hooks there would probably be bad.

  (Somewhat edited from Nicolas' original patch.)

Signed-off-by: Nikodemus Siivola <nikodemus@random-state.net>
NEWS
src/code/run-program.lisp
src/runtime/run-program.c
tests/run-program.impure.lisp