Skip to content

Commit a654bcc

Browse files
committed
platform-specific process killing
1 parent df82d57 commit a654bcc

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ env:
1717
jobs:
1818
lint:
1919
runs-on: ubuntu-latest
20+
concurrency:
21+
group: tests-${{ github.workflow }}-${{ github.event.number || github.ref }}
22+
cancel-in-progress: true
2023
permissions:
2124
id-token: write
2225
contents: read

cli/run.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,7 @@ Run 'dispatch help run' to learn about Dispatch sessions.`, BridgeSession)
205205
s = os.Kill
206206
}
207207
if cmd.Process != nil && cmd.Process.Pid > 0 {
208-
// Sending the signal to -pid sends it to all processes
209-
// in the process group.
210-
_ = syscall.Kill(-cmd.Process.Pid, s.(syscall.Signal))
208+
killProcess(cmd.Process, s.(syscall.Signal))
211209
}
212210
}
213211
}

cli/run_darwin.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package cli
22

3-
import "syscall"
3+
import (
4+
"os"
5+
"syscall"
6+
)
47

58
func setSysProcAttr(attr *syscall.SysProcAttr) {
69
attr.Setpgid = true
710
}
11+
12+
func killProcess(process *os.Process, signal os.Signal) {
13+
// Sending the signal to -pid sends it to all processes
14+
// in the process group.
15+
_ = syscall.Kill(-process.Pid, signal.(syscall.Signal))
16+
}

cli/run_linux.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
package cli
22

3-
import "syscall"
3+
import (
4+
"os"
5+
"syscall"
6+
)
47

58
func setSysProcAttr(attr *syscall.SysProcAttr) {
69
attr.Setpgid = true
710
attr.Pdeathsig = syscall.SIGTERM
811
}
12+
13+
func killProcess(process *os.Process, signal os.Signal) {
14+
// Sending the signal to -pid sends it to all processes
15+
// in the process group.
16+
_ = syscall.Kill(-process.Pid, signal.(syscall.Signal))
17+
}

cli/run_windows.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package cli
2+
3+
import "os"
4+
5+
func killProcess(process *os.Process, _ os.Signal) {
6+
process.Kill()
7+
}

0 commit comments

Comments
 (0)