help-bash
[Top][All Lists]
Advanced

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

why is the pipeline_pgrp reset to 0 only when the pipeline_pgrp and shel


From: wang yuhang
Subject: why is the pipeline_pgrp reset to 0 only when the pipeline_pgrp and shell_pgrp are different
Date: Wed, 15 Mar 2023 22:20:50 +0800

Hello

I use the fork bomb to start the process. When the number of processes reaches 
the maximum limit with command "ulimit -u". In bash version 5.1, function 
terminate_current_pipeline does not send sigterm signal, just because pipeline_ 
pgrp is the same with shell_pgrp.


I found bash-5.1 the following difference compared with bash-5.0
```
+jobs.c
+       - {start,stop}_pipeline: don't reset pipeline_pgrp to 0 if it's already
+         the same as shell_pgrp, since we don't want to reset it in the 
middle
+         of a shell started to run a command or process substitution 
(after
+         forking a child to run one command, but before forking another, 
for
+       &nbsp; instance). Reported by Rob Landley <rob@landley.net&gt;
```


```
diff --git a/jobs.c b/jobs.c
index b791900..f98e2e6 100644
--- a/jobs.c
+++ b/jobs.c
@@ -519,7 +519,12 @@ start_pipeline ()
&nbsp; &nbsp;if (the_pipeline)
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp;cleanup_the_pipeline ();
-&nbsp; &nbsp; &nbsp; pipeline_pgrp = 0;
+&nbsp; &nbsp; &nbsp; /* If job_control == 0, pipeline_pgrp will always be 
equal to shell_pgrp;
+        if job_control != 0, pipeline_pgrp == shell_pgrp for command and
+        process substitution, in which case we want it to be the same as
+        shell_pgrp for the lifetime of this shell instance. */
+&nbsp; &nbsp; &nbsp; if (pipeline_pgrp != shell_pgrp)
+       pipeline_pgrp = 0;
&nbsp;#if defined (PGRP_PIPE)
&nbsp; &nbsp; &nbsp; &nbsp;sh_closepipe (pgrp_pipe);
&nbsp;#endif
@@ -632,7 +637,8 @@ stop_pipeline (async, deferred)
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;the_pipeline = (PROCESS *)NULL;
&nbsp; &nbsp; &nbsp; &nbsp;newjob-&gt;pgrp = pipeline_pgrp;
-&nbsp; &nbsp; &nbsp; pipeline_pgrp = 0;
+&nbsp; &nbsp; &nbsp; if (pipeline_pgrp != shell_pgrp)
+       pipeline_pgrp = 0;
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;newjob-&gt;flags = 0;
&nbsp; &nbsp; &nbsp; &nbsp;if (pipefail_opt)

```


I'm sorry I can't find the original issue. Could you tell me why is the 
pipeline_pgrp reset to 0 only when the pipeline_pgrp and shell_pgrp are 
different?&nbsp;


Thanks !

reply via email to

[Prev in Thread] Current Thread [Next in Thread]