diff --git a/tests/client_connectivity_test.go b/tests/client_connectivity_test.go index b20f5fd..830bf97 100644 --- a/tests/client_connectivity_test.go +++ b/tests/client_connectivity_test.go @@ -5,6 +5,7 @@ import ( "net/http" "os" "os/exec" + "strconv" "sync" "sync/atomic" "testing" @@ -125,13 +126,12 @@ func TestSigkillBeforeKeysUploadResponse(t *testing.T) { terminateClient = func() { terminated.Store(true) t.Logf("got keys/upload: terminating process %v", cmd.Process.Pid) - if err := cmd.Process.Kill(); err != nil { + kill := exec.Command("kill", "-USR2", strconv.Itoa(cmd.Process.Pid)) + t.Logf(kill.String()) + if err := kill.Run(); err != nil { t.Errorf("failed to kill process: %s", err) return } - if err := cmd.Wait(); err != nil { - t.Logf("error waiting for process to quit: %v", err) - } t.Logf("terminated process") waiter.Finish() } diff --git a/tests/templates/sigkill_before_keys_upload_response.go b/tests/templates/sigkill_before_keys_upload_response.go index 9f5bc0e..58780dd 100644 --- a/tests/templates/sigkill_before_keys_upload_response.go +++ b/tests/templates/sigkill_before_keys_upload_response.go @@ -3,6 +3,8 @@ package main import ( "fmt" "os" + "os/signal" + "syscall" "time" "github.com/matrix-org/complement-crypto/internal/api" @@ -24,7 +26,18 @@ func (t *MockT) Fatalf(f string, args ...any) { } func (t *MockT) Name() string { return "inline_script" } +func ProcessSignal() { + sigch := make(chan os.Signal, 2) + signal.Notify(sigch, syscall.SIGUSR2) + for { + signalType := <-sigch + fmt.Println("Received signal SIGUSR2 from channel : ", signalType) + panic("terminating...") + } +} + func main() { + go ProcessSignal() time.Sleep(time.Second) t := &MockT{} cfg := api.ClientCreationOpts{