# HG changeset patch # User Matt Johnston # Date 1092847328 0 # Node ID b8e36c1a5520b381142c8b684593096be4712f93 # Parent b855bf63766c4c1c3018602ea3aaa5a7f1937857 Mention the race condition between setting the childpid entry, and the child exiting. diff -r b855bf63766c -r b8e36c1a5520 svr-chansession.c --- a/svr-chansession.c Wed Aug 18 16:31:05 2004 +0000 +++ b/svr-chansession.c Wed Aug 18 16:42:08 2004 +0000 @@ -78,7 +78,6 @@ TRACE(("enter sigchld handler")); while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { - /* find the corresponding chansess */ for (i = 0; i < svr_ses.childpidsize; i++) { if (svr_ses.childpids[i].pid == pid) { @@ -630,7 +629,10 @@ TRACE(("continue noptycommand: parent")); chansess->pid = pid; - /* add a child pid */ + /* add a child pid - Beware: there's a race between this, and the + * exec() called from the child. If the child finishes before we've + * done this (ie if it was a shell builtin and fast), we won't return a + * proper return code. For now, we ignore this case. */ addchildpid(chansess, pid); close(infds[FDIN]);