Hello! I would like to suggest another code refactor, which could make the code easier to maintain. This is a result of my study of spawn() vs fork() differences and ways to implement runtime switching between spawn() and fork() in a simple way. The idea is to unify child_execute_job() function. The unification can be done in the following way: 1. The function will always return child's PID. 2. On UNIX the function will call fork() in order to create a child by itself. 3. job_fds[] and job_rfd can be handled in spawn() way in both cases. Currently the differences are: a) fork() version calls fork(), then closes descriptors in the child explicitly. b) spawn() version sets FD_CLOEXEC flags for these fd's, then calls spawn(). This effectively means that these descriptors are not inherited by the child. After spawn()ing FD_CLOEXEC flag is reset. I suggest that (b) approach can also be used on UNIX without bad effects. We could FD_CLONEXEC for relevand fds, then call child_execute_job() which does fork(). The effect should be the same as closing fd's in the child manually. I suggest that parent process can even skip resetting this flag since Make AFAIK never replaces itself with some other process which needs to inherit all internal file descriptors. So, the code can be further simplified. Any thoughts / pros / contras ?
Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make