Hi.
Since posix_spawn is being discussed, I'd like to report a what I think is a bug in the current implementation:
Since the child is unmasking its signals only after it's performed its file actions, the process may get blocked indefinitely (e.g., on a FIFO open) while being unresponsive to signals.
Example program (with close to no error checking):
posix_spawn_file_actions_t fa;
posix_spawn_file_actions_init(&fa);
posix_spawn_file_actions_addopen(&fa, 0, "fifo", O_RDONLY, 0);
posix_spawnp(&pid, "tr", &fa, 0, (char *const[]){ "tr", "a-z", "A-Z", 0}, environ);
//will get stuck here
It think the pthread_mask call should be moved above the file actions, which fixes this problem.
Additionally, as far as extensions to the current POSIX standard are concerned, adding the herein (
http://austingroupbugs.net/view.php?id=411) proposed change to *adddup2 semantics (clearing the FD_CLOEXEC flag on the (given target in dup2 file actions where the source and target filedescriptor are identical) would be super nice (the reasoning for it should be in the link).
Finally, I noticed the error passing code can be reduced to a simple write to a volatile int made from the child (purely cosmetic).
Attached are patches for these 3 things in case you wanted them. (I hope I'm not doing something stupid.)
Best regards and thanks for the project!