new deploy: 2022-06-10T16:10:44+00:00
parent
0afe3aa993
commit
974cb9f512
|
@ -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> &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
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -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> <-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
|
||||||
|
@ -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
|
@ -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> &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
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -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> &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
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -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> &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
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -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> &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
|
||||||
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue