Index: dmake/unix/runargv.c =================================================================== RCS file: /cvs/tools/dmake/unix/runargv.c,v retrieving revision 1.8.6.4 diff -u -r1.8.6.4 runargv.c --- dmake/unix/runargv.c 7 Sep 2005 01:39:50 -0000 1.8.6.4 +++ dmake/unix/runargv.c 15 Sep 2005 00:04:23 -0000 @@ -58,8 +58,6 @@ If pid = -1 wait for the next child process to finish. If Wait_for_completion is set handle all finished processes until the process with the given pid is reached. - If Shell_exec_target (global variable) is set wait and handle only the given - pid. _finished_child(pid, ?) [unix/runargv] removes the finished child from its process queue. If there are more commands in this queue start the next @@ -161,8 +159,9 @@ * command is called as part of a shell escape in a recipe make sure that all * previous recipe lines of this target have finished. */ if( Is_exec_shell ) { - if( (st_pq = _running(Shell_exec_target)) != -1 ) + if( (st_pq = _running(Shell_exec_target)) != -1 ) { Wait_for_child(FALSE, _procs[st_pq].pr_pid); + } } else { if( _running(target) != -1 /*&& Max_proc != 1*/ ) { /* The command will be executed when the previous recipe @@ -240,22 +239,26 @@ int status; int waitchild; int is_exec_shell_status = Is_exec_shell; + int wait_for_completion_status = Wait_for_completion; /* It is impossible that processes that were started from _exec_shell * have follow-up commands in its process queue. Unset Is_exec_shell * to prevent piping of child processes that are started from the - * _finished_child subroutine. */ + * _finished_child subroutine and reset to its original value when + * leaving this function. */ + Is_exec_shell = FALSE; waitchild = (pid == -1)? FALSE : Wait_for_completion; + /* Subroutines of _finished_child can reach Exec_commands. This + * can change Wait_for_completion. Make sure that it is reset to its + * original value when leaving this function. */ + do { - if( Is_exec_shell ) { /* For pid == -1 waitpid behaves like wait. */ - wid = waitpid(pid, &status, 0); - Is_exec_shell = FALSE; - } else - wid = wait(&status); + wid = wait(&status); if( wid == -1 ) { + Wait_for_completion = wait_for_completion_status; Is_exec_shell = is_exec_shell_status; return(-1); } @@ -266,6 +269,7 @@ } while( waitchild && pid != wid ); + Wait_for_completion = wait_for_completion_status; Is_exec_shell = is_exec_shell_status; return(0); }