Possible race condition in ProcessUNIX process creation

When creating a process in kwsysProcessCreate, we create a pgidPipe which gets closed when the child does the execvp call. After fork, parent reads the pgidPipe until it returns EOF or an error. There is a race condition if the parent’s blocking read call wakes up only after the child has already exited, leading to SIGCHLD and read returning -1 with EINTR. Linux probably does handle this and makes sure EOF is reported before EINTR but POSIX makes no such guarantees. I was digging around as my OS’s cmake port was failing to do any quick child invocations. The fix would be to either block SIGCHILD in addition to SIGINT and SIGTERM at the start, or handle EINTR return from pgidPipe read. I attached a patch with latter fix.

(attachments)

0001-ProcessUNIX-Fix-possible-race-condition.patch (997 Bytes)