Re: Regression in dash 0.5.10 related to subshells

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 06, 2018 at 12:02:43AM +0800, Herbert Xu wrote:
> Subject: jobs - Do not block when waiting on SIGCHLD

> Because of the nature of SIGCHLD, the process may have already been
> waited on and therefore we must be prepared for the case that wait
> may block.  So ensure that it doesn't by using WNOHANG.

> Fixes: 03876c0743a5 ("eval: Reap zombies after built-in...")
> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

> diff --git a/src/jobs.c b/src/jobs.c
> index 1a97c54..6dc555f 100644
> --- a/src/jobs.c
> +++ b/src/jobs.c
> @@ -975,8 +975,8 @@ waitforjob(struct job *jp)
>  	int st;
>  
>  	TRACE(("waitforjob(%%%d) called\n", jp ? jobno(jp) : 0));
> -	while ((jp && jp->state == JOBRUNNING) || gotsigchld)
> -		dowait(DOWAIT_BLOCK, jp);
> +	while (jp ? jp->state == JOBRUNNING : gotsigchld)
> +		dowait(jp ? DOWAIT_BLOCK : DOWAIT_NORMAL, jp);
>  	if (!jp)
>  		return exitstatus;
>  	st = getstatus(jp);

Now each of the first four executable lines of waitforjob() does
something different for jp == NULL and jp != NULL. It probably makes
more sense to separate the jp == NULL case into a new function.

-- 
Jilles Tjoelker
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux