new deploy: 2022-06-10T16:10:44+00:00

pages
Loïc Dachary 2022-06-10 16:10:44 +00:00 committed by dachary
parent 0afe3aa993
commit 974cb9f512
7 changed files with 85 additions and 103 deletions

View File

@ -30,7 +30,7 @@
<blockquote> <blockquote>
<p>If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.</p> <p>If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.</p>
</blockquote> </blockquote>
<p>Which is implemented as follows in the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec.go#L79">Friendly Forge Format library</a>:</p> <p>Which is implemented as follows in the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec.go#L130">Friendly Forge Format library</a>:</p>
<blockquote> <blockquote>
<p><code>syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)</code></p> <p><code>syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)</code></p>
</blockquote> </blockquote>
@ -38,18 +38,15 @@
><span class="anchor-icon">#</span></a ><span class="anchor-icon">#</span></a
> >
</h3> </h3>
<p>Since <a href="https://pkg.go.dev/os/exec#CommandContext">CommandContext</a> does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec.go#L71-87">Friendly Forge Format library</a> does it:</p> <p>Since <a href="https://pkg.go.dev/os/exec#CommandContext">CommandContext</a> does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec.go#L75-82">Friendly Forge Format library</a> does it:</p>
<pre style="background-color:#2b303b;color:#c0c5ce;"><code><span> err := cmd.Start() <pre style="background-color:#2b303b;color:#c0c5ce;"><code><span> ctxErr := watchCtx(ctx, cmd.Process.Pid)
</span><span>...
</span><span> go func() {
</span><span> <-ctx.Done()
</span><span>
</span><span> if killErr := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL); killErr == nil {
</span><span>...
</span><span> }
</span><span> }()
</span><span>
</span><span> err = cmd.Wait() </span><span> err = cmd.Wait()
</span><span> interruptErr := <-ctxErr
</span><span> // If cmd.Wait returned an error, prefer that.
</span><span> // Otherwise, report any error from the interrupt goroutine.
</span><span> if interruptErr != nil && err == nil {
</span><span> err = interruptErr
</span><span> }
</span></code></pre> </span></code></pre>
<h3 id="testing-the-bug-is-fixed-and-stays-fixed">Testing the bug is fixed and stays fixed<a class="zola-anchor" href="#testing-the-bug-is-fixed-and-stays-fixed" aria-label="Anchor link for: testing-the-bug-is-fixed-and-stays-fixed" <h3 id="testing-the-bug-is-fixed-and-stays-fixed">Testing the bug is fixed and stays fixed<a class="zola-anchor" href="#testing-the-bug-is-fixed-and-stays-fixed" aria-label="Anchor link for: testing-the-bug-is-fixed-and-stays-fixed"
><span class="anchor-icon">#</span></a ><span class="anchor-icon">#</span></a
@ -61,12 +58,12 @@
<li>the bug fix works</li> <li>the bug fix works</li>
<li>it does not resurface insidiously because of a subtle regression introduce years later</li> <li>it does not resurface insidiously because of a subtle regression introduce years later</li>
</ul> </ul>
<p>It is easy to implement as can be seen in the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L44-76">Friendly Forge Format library</a>. In a nutshell:</p> <p>It is easy to implement as can be seen in the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L44-76">Friendly Forge Format library</a>. In a nutshell:</p>
<ul> <ul>
<li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L53">git clone https://4.4.4.4</a> which will hang because of firewall rules</li> <li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L53">git clone https://4.4.4.4</a> which will hang because of firewall rules</li>
<li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L60-65">wait for the git-remote-https</a> grandchild process to be spawned</li> <li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L60-65">wait for the git-remote-https</a> grandchild process to be spawned</li>
<li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L67-68">cancel the context and wait for the goroutine to terminate</a></li> <li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L67-68">cancel the context and wait for the goroutine to terminate</a></li>
<li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L70-75">verify the git-remote-https is killed</a></li> <li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L70-75">verify the git-remote-https is killed</a></li>
</ul> </ul>
<p>And with that... no more zombies!</p> <p>And with that... no more zombies!</p>
</content> </content>

View File

@ -234,7 +234,7 @@
<blockquote> <blockquote>
<p>If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.</p> <p>If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.</p>
</blockquote> </blockquote>
<p>Which is implemented as follows in the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec.go#L79">Friendly Forge Format library</a>:</p> <p>Which is implemented as follows in the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec.go#L130">Friendly Forge Format library</a>:</p>
<blockquote> <blockquote>
<p><code>syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)</code></p> <p><code>syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)</code></p>
</blockquote> </blockquote>
@ -242,18 +242,15 @@
><span class="anchor-icon">#</span></a ><span class="anchor-icon">#</span></a
> >
</h3> </h3>
<p>Since <a href="https://pkg.go.dev/os/exec#CommandContext">CommandContext</a> does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec.go#L71-87">Friendly Forge Format library</a> does it:</p> <p>Since <a href="https://pkg.go.dev/os/exec#CommandContext">CommandContext</a> does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec.go#L75-82">Friendly Forge Format library</a> does it:</p>
<pre style="background-color:#2b303b;color:#c0c5ce;"><code><span> err := cmd.Start() <pre style="background-color:#2b303b;color:#c0c5ce;"><code><span> ctxErr := watchCtx(ctx, cmd.Process.Pid)
</span><span>...
</span><span> go func() {
</span><span> &lt;-ctx.Done()
</span><span>
</span><span> if killErr := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL); killErr == nil {
</span><span>...
</span><span> }
</span><span> }()
</span><span>
</span><span> err = cmd.Wait() </span><span> err = cmd.Wait()
</span><span> interruptErr := &lt;-ctxErr
</span><span> // If cmd.Wait returned an error, prefer that.
</span><span> // Otherwise, report any error from the interrupt goroutine.
</span><span> if interruptErr != nil &amp;&amp; err == nil {
</span><span> err = interruptErr
</span><span> }
</span></code></pre> </span></code></pre>
<h3 id="testing-the-bug-is-fixed-and-stays-fixed">Testing the bug is fixed and stays fixed<a class="zola-anchor" href="#testing-the-bug-is-fixed-and-stays-fixed" aria-label="Anchor link for: testing-the-bug-is-fixed-and-stays-fixed" <h3 id="testing-the-bug-is-fixed-and-stays-fixed">Testing the bug is fixed and stays fixed<a class="zola-anchor" href="#testing-the-bug-is-fixed-and-stays-fixed" aria-label="Anchor link for: testing-the-bug-is-fixed-and-stays-fixed"
><span class="anchor-icon">#</span></a ><span class="anchor-icon">#</span></a
@ -265,12 +262,12 @@
<li>the bug fix works</li> <li>the bug fix works</li>
<li>it does not resurface insidiously because of a subtle regression introduce years later</li> <li>it does not resurface insidiously because of a subtle regression introduce years later</li>
</ul> </ul>
<p>It is easy to implement as can be seen in the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L44-76">Friendly Forge Format library</a>. In a nutshell:</p> <p>It is easy to implement as can be seen in the <a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L44-76">Friendly Forge Format library</a>. In a nutshell:</p>
<ul> <ul>
<li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L53">git clone https://4.4.4.4</a> which will hang because of firewall rules</li> <li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L53">git clone https://4.4.4.4</a> which will hang because of firewall rules</li>
<li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L60-65">wait for the git-remote-https</a> grandchild process to be spawned</li> <li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L60-65">wait for the git-remote-https</a> grandchild process to be spawned</li>
<li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L67-68">cancel the context and wait for the goroutine to terminate</a></li> <li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L67-68">cancel the context and wait for the goroutine to terminate</a></li>
<li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/f42a29284a5262d3e6f94801089369626c5197f6/util/exec_test.go#L70-75">verify the git-remote-https is killed</a></li> <li><a href="https://lab.forgefriends.org/friendlyforgeformat/gofff/-/blob/a9603c7cc934fccd4382b7f4309b75c852742480/util/exec_test.go#L70-75">verify the git-remote-https is killed</a></li>
</ul> </ul>
<p>And with that... no more zombies!</p> <p>And with that... no more zombies!</p>

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,7 @@
&lt;blockquote&gt; &lt;blockquote&gt;
&lt;p&gt;If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.&lt;&#x2F;p&gt; &lt;p&gt;If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt; &lt;&#x2F;blockquote&gt;
&lt;p&gt;Which is implemented as follows in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec.go#L79&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt; &lt;p&gt;Which is implemented as follows in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec.go#L130&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;blockquote&gt; &lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)&lt;&#x2F;code&gt;&lt;&#x2F;p&gt; &lt;p&gt;&lt;code&gt;syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt; &lt;&#x2F;blockquote&gt;
@ -38,18 +38,15 @@
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a &gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt; &gt;
&lt;&#x2F;h3&gt; &lt;&#x2F;h3&gt;
&lt;p&gt;Since &lt;a href=&quot;https:&#x2F;&#x2F;pkg.go.dev&#x2F;os&#x2F;exec#CommandContext&quot;&gt;CommandContext&lt;&#x2F;a&gt; does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec.go#L71-87&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt; does it:&lt;&#x2F;p&gt; &lt;p&gt;Since &lt;a href=&quot;https:&#x2F;&#x2F;pkg.go.dev&#x2F;os&#x2F;exec#CommandContext&quot;&gt;CommandContext&lt;&#x2F;a&gt; does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec.go#L75-82&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt; does it:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt; err := cmd.Start() &lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt; ctxErr := watchCtx(ctx, cmd.Process.Pid)
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt; go func() {
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;-ctx.Done()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; if killErr := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL); killErr == nil {
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;span&gt; }()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; err = cmd.Wait() &lt;&#x2F;span&gt;&lt;span&gt; err = cmd.Wait()
&lt;&#x2F;span&gt;&lt;span&gt; interruptErr := &amp;lt;-ctxErr
&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;&#x2F; If cmd.Wait returned an error, prefer that.
&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;&#x2F; Otherwise, report any error from the interrupt goroutine.
&lt;&#x2F;span&gt;&lt;span&gt; if interruptErr != nil &amp;amp;&amp;amp; err == nil {
&lt;&#x2F;span&gt;&lt;span&gt; err = interruptErr
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt; &lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;testing-the-bug-is-fixed-and-stays-fixed&quot;&gt;Testing the bug is fixed and stays fixed&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-the-bug-is-fixed-and-stays-fixed&quot; aria-label=&quot;Anchor link for: testing-the-bug-is-fixed-and-stays-fixed&quot; &lt;h3 id=&quot;testing-the-bug-is-fixed-and-stays-fixed&quot;&gt;Testing the bug is fixed and stays fixed&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-the-bug-is-fixed-and-stays-fixed&quot; aria-label=&quot;Anchor link for: testing-the-bug-is-fixed-and-stays-fixed&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a &gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
@ -61,12 +58,12 @@
&lt;li&gt;the bug fix works&lt;&#x2F;li&gt; &lt;li&gt;the bug fix works&lt;&#x2F;li&gt;
&lt;li&gt;it does not resurface insidiously because of a subtle regression introduce years later&lt;&#x2F;li&gt; &lt;li&gt;it does not resurface insidiously because of a subtle regression introduce years later&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt; &lt;&#x2F;ul&gt;
&lt;p&gt;It is easy to implement as can be seen in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L44-76&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;. In a nutshell:&lt;&#x2F;p&gt; &lt;p&gt;It is easy to implement as can be seen in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L44-76&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;. In a nutshell:&lt;&#x2F;p&gt;
&lt;ul&gt; &lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L53&quot;&gt;git clone https:&#x2F;&#x2F;4.4.4.4&lt;&#x2F;a&gt; which will hang because of firewall rules&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L53&quot;&gt;git clone https:&#x2F;&#x2F;4.4.4.4&lt;&#x2F;a&gt; which will hang because of firewall rules&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L60-65&quot;&gt;wait for the git-remote-https&lt;&#x2F;a&gt; grandchild process to be spawned&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L60-65&quot;&gt;wait for the git-remote-https&lt;&#x2F;a&gt; grandchild process to be spawned&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L67-68&quot;&gt;cancel the context and wait for the goroutine to terminate&lt;&#x2F;a&gt;&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L67-68&quot;&gt;cancel the context and wait for the goroutine to terminate&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L70-75&quot;&gt;verify the git-remote-https is killed&lt;&#x2F;a&gt;&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L70-75&quot;&gt;verify the git-remote-https is killed&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt; &lt;&#x2F;ul&gt;
&lt;p&gt;And with that... no more zombies!&lt;&#x2F;p&gt; &lt;p&gt;And with that... no more zombies!&lt;&#x2F;p&gt;
</content> </content>

View File

@ -30,7 +30,7 @@
&lt;blockquote&gt; &lt;blockquote&gt;
&lt;p&gt;If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.&lt;&#x2F;p&gt; &lt;p&gt;If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt; &lt;&#x2F;blockquote&gt;
&lt;p&gt;Which is implemented as follows in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec.go#L79&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt; &lt;p&gt;Which is implemented as follows in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec.go#L130&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;blockquote&gt; &lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)&lt;&#x2F;code&gt;&lt;&#x2F;p&gt; &lt;p&gt;&lt;code&gt;syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt; &lt;&#x2F;blockquote&gt;
@ -38,18 +38,15 @@
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a &gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt; &gt;
&lt;&#x2F;h3&gt; &lt;&#x2F;h3&gt;
&lt;p&gt;Since &lt;a href=&quot;https:&#x2F;&#x2F;pkg.go.dev&#x2F;os&#x2F;exec#CommandContext&quot;&gt;CommandContext&lt;&#x2F;a&gt; does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec.go#L71-87&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt; does it:&lt;&#x2F;p&gt; &lt;p&gt;Since &lt;a href=&quot;https:&#x2F;&#x2F;pkg.go.dev&#x2F;os&#x2F;exec#CommandContext&quot;&gt;CommandContext&lt;&#x2F;a&gt; does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec.go#L75-82&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt; does it:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt; err := cmd.Start() &lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt; ctxErr := watchCtx(ctx, cmd.Process.Pid)
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt; go func() {
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;-ctx.Done()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; if killErr := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL); killErr == nil {
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;span&gt; }()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; err = cmd.Wait() &lt;&#x2F;span&gt;&lt;span&gt; err = cmd.Wait()
&lt;&#x2F;span&gt;&lt;span&gt; interruptErr := &amp;lt;-ctxErr
&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;&#x2F; If cmd.Wait returned an error, prefer that.
&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;&#x2F; Otherwise, report any error from the interrupt goroutine.
&lt;&#x2F;span&gt;&lt;span&gt; if interruptErr != nil &amp;amp;&amp;amp; err == nil {
&lt;&#x2F;span&gt;&lt;span&gt; err = interruptErr
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt; &lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;testing-the-bug-is-fixed-and-stays-fixed&quot;&gt;Testing the bug is fixed and stays fixed&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-the-bug-is-fixed-and-stays-fixed&quot; aria-label=&quot;Anchor link for: testing-the-bug-is-fixed-and-stays-fixed&quot; &lt;h3 id=&quot;testing-the-bug-is-fixed-and-stays-fixed&quot;&gt;Testing the bug is fixed and stays fixed&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-the-bug-is-fixed-and-stays-fixed&quot; aria-label=&quot;Anchor link for: testing-the-bug-is-fixed-and-stays-fixed&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a &gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
@ -61,12 +58,12 @@
&lt;li&gt;the bug fix works&lt;&#x2F;li&gt; &lt;li&gt;the bug fix works&lt;&#x2F;li&gt;
&lt;li&gt;it does not resurface insidiously because of a subtle regression introduce years later&lt;&#x2F;li&gt; &lt;li&gt;it does not resurface insidiously because of a subtle regression introduce years later&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt; &lt;&#x2F;ul&gt;
&lt;p&gt;It is easy to implement as can be seen in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L44-76&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;. In a nutshell:&lt;&#x2F;p&gt; &lt;p&gt;It is easy to implement as can be seen in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L44-76&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;. In a nutshell:&lt;&#x2F;p&gt;
&lt;ul&gt; &lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L53&quot;&gt;git clone https:&#x2F;&#x2F;4.4.4.4&lt;&#x2F;a&gt; which will hang because of firewall rules&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L53&quot;&gt;git clone https:&#x2F;&#x2F;4.4.4.4&lt;&#x2F;a&gt; which will hang because of firewall rules&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L60-65&quot;&gt;wait for the git-remote-https&lt;&#x2F;a&gt; grandchild process to be spawned&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L60-65&quot;&gt;wait for the git-remote-https&lt;&#x2F;a&gt; grandchild process to be spawned&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L67-68&quot;&gt;cancel the context and wait for the goroutine to terminate&lt;&#x2F;a&gt;&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L67-68&quot;&gt;cancel the context and wait for the goroutine to terminate&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L70-75&quot;&gt;verify the git-remote-https is killed&lt;&#x2F;a&gt;&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L70-75&quot;&gt;verify the git-remote-https is killed&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt; &lt;&#x2F;ul&gt;
&lt;p&gt;And with that... no more zombies!&lt;&#x2F;p&gt; &lt;p&gt;And with that... no more zombies!&lt;&#x2F;p&gt;
</content> </content>

View File

@ -30,7 +30,7 @@
&lt;blockquote&gt; &lt;blockquote&gt;
&lt;p&gt;If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.&lt;&#x2F;p&gt; &lt;p&gt;If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt; &lt;&#x2F;blockquote&gt;
&lt;p&gt;Which is implemented as follows in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec.go#L79&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt; &lt;p&gt;Which is implemented as follows in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec.go#L130&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;blockquote&gt; &lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)&lt;&#x2F;code&gt;&lt;&#x2F;p&gt; &lt;p&gt;&lt;code&gt;syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt; &lt;&#x2F;blockquote&gt;
@ -38,18 +38,15 @@
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a &gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt; &gt;
&lt;&#x2F;h3&gt; &lt;&#x2F;h3&gt;
&lt;p&gt;Since &lt;a href=&quot;https:&#x2F;&#x2F;pkg.go.dev&#x2F;os&#x2F;exec#CommandContext&quot;&gt;CommandContext&lt;&#x2F;a&gt; does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec.go#L71-87&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt; does it:&lt;&#x2F;p&gt; &lt;p&gt;Since &lt;a href=&quot;https:&#x2F;&#x2F;pkg.go.dev&#x2F;os&#x2F;exec#CommandContext&quot;&gt;CommandContext&lt;&#x2F;a&gt; does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec.go#L75-82&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt; does it:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt; err := cmd.Start() &lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt; ctxErr := watchCtx(ctx, cmd.Process.Pid)
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt; go func() {
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;-ctx.Done()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; if killErr := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL); killErr == nil {
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;span&gt; }()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; err = cmd.Wait() &lt;&#x2F;span&gt;&lt;span&gt; err = cmd.Wait()
&lt;&#x2F;span&gt;&lt;span&gt; interruptErr := &amp;lt;-ctxErr
&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;&#x2F; If cmd.Wait returned an error, prefer that.
&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;&#x2F; Otherwise, report any error from the interrupt goroutine.
&lt;&#x2F;span&gt;&lt;span&gt; if interruptErr != nil &amp;amp;&amp;amp; err == nil {
&lt;&#x2F;span&gt;&lt;span&gt; err = interruptErr
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt; &lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;testing-the-bug-is-fixed-and-stays-fixed&quot;&gt;Testing the bug is fixed and stays fixed&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-the-bug-is-fixed-and-stays-fixed&quot; aria-label=&quot;Anchor link for: testing-the-bug-is-fixed-and-stays-fixed&quot; &lt;h3 id=&quot;testing-the-bug-is-fixed-and-stays-fixed&quot;&gt;Testing the bug is fixed and stays fixed&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-the-bug-is-fixed-and-stays-fixed&quot; aria-label=&quot;Anchor link for: testing-the-bug-is-fixed-and-stays-fixed&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a &gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
@ -61,12 +58,12 @@
&lt;li&gt;the bug fix works&lt;&#x2F;li&gt; &lt;li&gt;the bug fix works&lt;&#x2F;li&gt;
&lt;li&gt;it does not resurface insidiously because of a subtle regression introduce years later&lt;&#x2F;li&gt; &lt;li&gt;it does not resurface insidiously because of a subtle regression introduce years later&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt; &lt;&#x2F;ul&gt;
&lt;p&gt;It is easy to implement as can be seen in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L44-76&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;. In a nutshell:&lt;&#x2F;p&gt; &lt;p&gt;It is easy to implement as can be seen in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L44-76&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;. In a nutshell:&lt;&#x2F;p&gt;
&lt;ul&gt; &lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L53&quot;&gt;git clone https:&#x2F;&#x2F;4.4.4.4&lt;&#x2F;a&gt; which will hang because of firewall rules&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L53&quot;&gt;git clone https:&#x2F;&#x2F;4.4.4.4&lt;&#x2F;a&gt; which will hang because of firewall rules&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L60-65&quot;&gt;wait for the git-remote-https&lt;&#x2F;a&gt; grandchild process to be spawned&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L60-65&quot;&gt;wait for the git-remote-https&lt;&#x2F;a&gt; grandchild process to be spawned&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L67-68&quot;&gt;cancel the context and wait for the goroutine to terminate&lt;&#x2F;a&gt;&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L67-68&quot;&gt;cancel the context and wait for the goroutine to terminate&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L70-75&quot;&gt;verify the git-remote-https is killed&lt;&#x2F;a&gt;&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L70-75&quot;&gt;verify the git-remote-https is killed&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt; &lt;&#x2F;ul&gt;
&lt;p&gt;And with that... no more zombies!&lt;&#x2F;p&gt; &lt;p&gt;And with that... no more zombies!&lt;&#x2F;p&gt;
</content> </content>

View File

@ -30,7 +30,7 @@
&lt;blockquote&gt; &lt;blockquote&gt;
&lt;p&gt;If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.&lt;&#x2F;p&gt; &lt;p&gt;If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt; &lt;&#x2F;blockquote&gt;
&lt;p&gt;Which is implemented as follows in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec.go#L79&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt; &lt;p&gt;Which is implemented as follows in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec.go#L130&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;blockquote&gt; &lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)&lt;&#x2F;code&gt;&lt;&#x2F;p&gt; &lt;p&gt;&lt;code&gt;syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt; &lt;&#x2F;blockquote&gt;
@ -38,18 +38,15 @@
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a &gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
&gt; &gt;
&lt;&#x2F;h3&gt; &lt;&#x2F;h3&gt;
&lt;p&gt;Since &lt;a href=&quot;https:&#x2F;&#x2F;pkg.go.dev&#x2F;os&#x2F;exec#CommandContext&quot;&gt;CommandContext&lt;&#x2F;a&gt; does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec.go#L71-87&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt; does it:&lt;&#x2F;p&gt; &lt;p&gt;Since &lt;a href=&quot;https:&#x2F;&#x2F;pkg.go.dev&#x2F;os&#x2F;exec#CommandContext&quot;&gt;CommandContext&lt;&#x2F;a&gt; does not allow to send a signal to the negative pid of the child process, it has to be implemented by Gitea itself, in a way that is similar to how the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec.go#L75-82&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt; does it:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt; err := cmd.Start() &lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt; ctxErr := watchCtx(ctx, cmd.Process.Pid)
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt; go func() {
&lt;&#x2F;span&gt;&lt;span&gt; &amp;lt;-ctx.Done()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; if killErr := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL); killErr == nil {
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;span&gt; }()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt; err = cmd.Wait() &lt;&#x2F;span&gt;&lt;span&gt; err = cmd.Wait()
&lt;&#x2F;span&gt;&lt;span&gt; interruptErr := &amp;lt;-ctxErr
&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;&#x2F; If cmd.Wait returned an error, prefer that.
&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;&#x2F; Otherwise, report any error from the interrupt goroutine.
&lt;&#x2F;span&gt;&lt;span&gt; if interruptErr != nil &amp;amp;&amp;amp; err == nil {
&lt;&#x2F;span&gt;&lt;span&gt; err = interruptErr
&lt;&#x2F;span&gt;&lt;span&gt; }
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt; &lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;testing-the-bug-is-fixed-and-stays-fixed&quot;&gt;Testing the bug is fixed and stays fixed&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-the-bug-is-fixed-and-stays-fixed&quot; aria-label=&quot;Anchor link for: testing-the-bug-is-fixed-and-stays-fixed&quot; &lt;h3 id=&quot;testing-the-bug-is-fixed-and-stays-fixed&quot;&gt;Testing the bug is fixed and stays fixed&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-the-bug-is-fixed-and-stays-fixed&quot; aria-label=&quot;Anchor link for: testing-the-bug-is-fixed-and-stays-fixed&quot;
&gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a &gt;&lt;span class=&quot;anchor-icon&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a
@ -61,12 +58,12 @@
&lt;li&gt;the bug fix works&lt;&#x2F;li&gt; &lt;li&gt;the bug fix works&lt;&#x2F;li&gt;
&lt;li&gt;it does not resurface insidiously because of a subtle regression introduce years later&lt;&#x2F;li&gt; &lt;li&gt;it does not resurface insidiously because of a subtle regression introduce years later&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt; &lt;&#x2F;ul&gt;
&lt;p&gt;It is easy to implement as can be seen in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L44-76&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;. In a nutshell:&lt;&#x2F;p&gt; &lt;p&gt;It is easy to implement as can be seen in the &lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L44-76&quot;&gt;Friendly Forge Format library&lt;&#x2F;a&gt;. In a nutshell:&lt;&#x2F;p&gt;
&lt;ul&gt; &lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L53&quot;&gt;git clone https:&#x2F;&#x2F;4.4.4.4&lt;&#x2F;a&gt; which will hang because of firewall rules&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L53&quot;&gt;git clone https:&#x2F;&#x2F;4.4.4.4&lt;&#x2F;a&gt; which will hang because of firewall rules&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L60-65&quot;&gt;wait for the git-remote-https&lt;&#x2F;a&gt; grandchild process to be spawned&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L60-65&quot;&gt;wait for the git-remote-https&lt;&#x2F;a&gt; grandchild process to be spawned&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L67-68&quot;&gt;cancel the context and wait for the goroutine to terminate&lt;&#x2F;a&gt;&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L67-68&quot;&gt;cancel the context and wait for the goroutine to terminate&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;f42a29284a5262d3e6f94801089369626c5197f6&#x2F;util&#x2F;exec_test.go#L70-75&quot;&gt;verify the git-remote-https is killed&lt;&#x2F;a&gt;&lt;&#x2F;li&gt; &lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;lab.forgefriends.org&#x2F;friendlyforgeformat&#x2F;gofff&#x2F;-&#x2F;blob&#x2F;a9603c7cc934fccd4382b7f4309b75c852742480&#x2F;util&#x2F;exec_test.go#L70-75&quot;&gt;verify the git-remote-https is killed&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt; &lt;&#x2F;ul&gt;
&lt;p&gt;And with that... no more zombies!&lt;&#x2F;p&gt; &lt;p&gt;And with that... no more zombies!&lt;&#x2F;p&gt;
</content> </content>