dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [v3 PATCH 17/17] eval: Add vfork support
       [not found] ` <E1fJkIG-0005qH-BW@gondobar>
@ 2021-01-08 20:55   ` Harald van Dijk
  2021-01-12  6:11     ` [PATCH] jobs: Always reset SIGINT/SIGQUIT handlers Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Harald van Dijk @ 2021-01-08 20:55 UTC (permalink / raw)
  To: Herbert Xu, DASH Mailing List

On 18/05/2018 19:39, Herbert Xu wrote:
> This patch adds basic vfork support for the case of a simple command.
>...  
> @@ -879,17 +892,30 @@ forkchild(struct job *jp, union node *n, int mode)
>   		}
>   	}
>   	if (!oldlvl && iflag) {
> -		setsignal(SIGINT);
> -		setsignal(SIGQUIT);
> +		if (mode != FORK_BG) {
> +			setsignal(SIGINT);
> +			setsignal(SIGQUIT);
> +		}
>   		setsignal(SIGTERM);
>   	}
> +
> +	if (lvforked)
> +		return;
> +
>   	for (jp = curjob; jp; jp = jp->prev_job)
>   		freejob(jp);
>   }

This leaves SIGQUIT ignored in background jobs in interactive shells.

   ENV= dash -ic 'dash -c "kill -QUIT \$\$; echo huh" & wait'

As of dash 0.5.11, this prints "huh". Before, the subprocess process 
killed itself before it could print anything. Other shells do not leave 
SIGQUIT ignored.

(In a few other shells, this also prints "huh", but in those other 
shells, that is because the inner shell chooses to ignore SIGQUIT, not 
because the outer shell leaves it ignored.)

Cheers,
Harald van Dijk

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] jobs: Always reset SIGINT/SIGQUIT handlers
  2021-01-08 20:55   ` [v3 PATCH 17/17] eval: Add vfork support Harald van Dijk
@ 2021-01-12  6:11     ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-01-12  6:11 UTC (permalink / raw)
  To: Harald van Dijk; +Cc: DASH Mailing List

On Fri, Jan 08, 2021 at 08:55:41PM +0000, Harald van Dijk wrote:
> On 18/05/2018 19:39, Herbert Xu wrote:
> > This patch adds basic vfork support for the case of a simple command.
> > ...  @@ -879,17 +892,30 @@ forkchild(struct job *jp, union node *n, int
> > mode)
> >   		}
> >   	}
> >   	if (!oldlvl && iflag) {
> > -		setsignal(SIGINT);
> > -		setsignal(SIGQUIT);
> > +		if (mode != FORK_BG) {
> > +			setsignal(SIGINT);
> > +			setsignal(SIGQUIT);
> > +		}
> >   		setsignal(SIGTERM);
> >   	}
> > +
> > +	if (lvforked)
> > +		return;
> > +
> >   	for (jp = curjob; jp; jp = jp->prev_job)
> >   		freejob(jp);
> >   }
> 
> This leaves SIGQUIT ignored in background jobs in interactive shells.
> 
>   ENV= dash -ic 'dash -c "kill -QUIT \$\$; echo huh" & wait'
> 
> As of dash 0.5.11, this prints "huh". Before, the subprocess process killed
> itself before it could print anything. Other shells do not leave SIGQUIT
> ignored.
> 
> (In a few other shells, this also prints "huh", but in those other shells,
> that is because the inner shell chooses to ignore SIGQUIT, not because the
> outer shell leaves it ignored.)

Thanks for catching this.  I have no idea how that got in there
and it makes no sense whatsoever.  This patch removes the if
conditional.

Fixes: e94a964e7dd0 ("eval: Add vfork support")
Reported-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/src/jobs.c b/src/jobs.c
index 516786f..08c4f13 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -892,10 +892,8 @@ static void forkchild(struct job *jp, union node *n, int mode)
 		}
 	}
 	if (!oldlvl && iflag) {
-		if (mode != FORK_BG) {
-			setsignal(SIGINT);
-			setsignal(SIGQUIT);
-		}
+		setsignal(SIGINT);
+		setsignal(SIGQUIT);
 		setsignal(SIGTERM);
 	}
 
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-12  6:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20180518183844.zizl3xevlcm4gzsj@gondor.apana.org.au>
     [not found] ` <E1fJkIG-0005qH-BW@gondobar>
2021-01-08 20:55   ` [v3 PATCH 17/17] eval: Add vfork support Harald van Dijk
2021-01-12  6:11     ` [PATCH] jobs: Always reset SIGINT/SIGQUIT handlers Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).