-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(emissary): signal SIGINT/SIGTERM in windows correctly (#13693)
Signed-off-by: Michael Weibel <michael@helio.exchange>
- Loading branch information
Showing
3 changed files
with
134 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//go:build windows | ||
|
||
package os_specific | ||
|
||
import ( | ||
"os/exec" | ||
"sync" | ||
"syscall" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestKill(t *testing.T) { | ||
shell := "pwsh.exe" | ||
cmd := exec.Command(shell, "-c", `while(1) { sleep 600000 }`) | ||
|
||
_, err := StartCommand(cmd) | ||
require.NoError(t, err) | ||
|
||
var wg sync.WaitGroup | ||
go func() { | ||
wg.Add(1) | ||
defer wg.Done() | ||
|
||
err = cmd.Wait() | ||
// we'll get an exit code | ||
assert.Error(t, err) | ||
}() | ||
|
||
err = Kill(cmd.Process.Pid, syscall.SIGTERM) | ||
require.NoError(t, err) | ||
|
||
wg.Wait() | ||
} |