View | Details | Raw Unified | Return to issue 53148
Collapse All | Expand All

(-)dmake/unix/runargv.c (-9 / +13 lines)
Lines 58-65 Link Here
58
  If pid = -1 wait for the next child process to finish.
58
  If pid = -1 wait for the next child process to finish.
59
  If Wait_for_completion is set handle all finished processes until the
59
  If Wait_for_completion is set handle all finished processes until the
60
  process with the given pid is reached.
60
  process with the given pid is reached.
61
  If Shell_exec_target (global variable) is set wait and handle only the given
62
  pid.
63
61
64
_finished_child(pid, ?) [unix/runargv] removes the finished child from its
62
_finished_child(pid, ?) [unix/runargv] removes the finished child from its
65
  process queue. If there are more commands in this queue start the next
63
  process queue. If there are more commands in this queue start the next
Lines 161-168 Link Here
161
    * command is called as part of a shell escape in a recipe make sure that all
159
    * command is called as part of a shell escape in a recipe make sure that all
162
    * previous recipe lines of this target have finished. */
160
    * previous recipe lines of this target have finished. */
163
   if( Is_exec_shell ) {
161
   if( Is_exec_shell ) {
164
      if( (st_pq = _running(Shell_exec_target)) != -1 )
162
      if( (st_pq = _running(Shell_exec_target)) != -1 ) {
165
	 Wait_for_child(FALSE, _procs[st_pq].pr_pid);
163
	 Wait_for_child(FALSE, _procs[st_pq].pr_pid);
164
      }
166
   } else {
165
   } else {
167
      if( _running(target) != -1 /*&& Max_proc != 1*/ ) {
166
      if( _running(target) != -1 /*&& Max_proc != 1*/ ) {
168
	 /* The command will be executed when the previous recipe
167
	 /* The command will be executed when the previous recipe
Lines 240-261 Link Here
240
   int status;
239
   int status;
241
   int waitchild;
240
   int waitchild;
242
   int is_exec_shell_status = Is_exec_shell;
241
   int is_exec_shell_status = Is_exec_shell;
242
   int wait_for_completion_status = Wait_for_completion;
243
243
244
   /* It is impossible that processes that were started from _exec_shell
244
   /* It is impossible that processes that were started from _exec_shell
245
    * have follow-up commands in its process queue. Unset Is_exec_shell
245
    * have follow-up commands in its process queue. Unset Is_exec_shell
246
    * to prevent piping of child processes that are started from the
246
    * to prevent piping of child processes that are started from the
247
    * _finished_child subroutine. */
247
    * _finished_child subroutine and reset to its original value when
248
    * leaving this function. */
249
   Is_exec_shell = FALSE;
248
250
249
   waitchild = (pid == -1)? FALSE : Wait_for_completion;
251
   waitchild = (pid == -1)? FALSE : Wait_for_completion;
250
252
253
   /* Subroutines of _finished_child can reach Exec_commands. This
254
    * can change Wait_for_completion.  Make sure that it is reset to its
255
    * original value when leaving this function. */
256
251
   do {
257
   do {
252
      if( Is_exec_shell ) { /* For pid == -1 waitpid behaves like wait. */
258
      wid = wait(&status);
253
         wid = waitpid(pid, &status, 0);
254
	 Is_exec_shell = FALSE;
255
      } else
256
         wid = wait(&status);
257
259
258
      if( wid  == -1 ) {
260
      if( wid  == -1 ) {
261
	 Wait_for_completion = wait_for_completion_status;
259
	 Is_exec_shell = is_exec_shell_status;
262
	 Is_exec_shell = is_exec_shell_status;
260
	 return(-1);
263
	 return(-1);
261
      }
264
      }
Lines 266-271 Link Here
266
   }
269
   }
267
   while( waitchild && pid != wid );
270
   while( waitchild && pid != wid );
268
271
272
   Wait_for_completion = wait_for_completion_status;
269
   Is_exec_shell = is_exec_shell_status;
273
   Is_exec_shell = is_exec_shell_status;
270
   return(0);
274
   return(0);
271
}
275
}

Return to issue 53148