canonical / matter-pi-gpio-commander

Matter Raspberry Pi GPIO Commander - Turn your Pi into a Matter lighting device!
Apache License 2.0
94 stars 2 forks source link

Cancelation of process with Context and Timeout/Deadline on GH Runner only kills the parent #49

Open locnnil opened 7 months ago

locnnil commented 7 months ago

If a process is expected to be killed after a timeout with utils.ExecContext or utils.ExecContextVerbose when running inside a GH runner it's only killed the parent process and not the child ones.

farshidtz commented 7 months ago

The issue isn't related to just cancellation via context. Reaching the timeout or deadline triggers the cancellation, which in turn kills the process. The same behavior should be expected when using os.Process.Kill.

The affected functions are tested here: https://github.com/canonical/matter-snap-testing/blob/c15a6cdfc5419f574ce928f0ab1d29bab4cd37fd/utils/exec_test.go#L54-L65

and a recent run show that the timeout results in killing the process after 1 second:

=== RUN   TestExec/context_timed_out
2024/02/20 16:06:41 [exec] sleep 3
...
--- PASS: TestExec (2.11s)
    ...
    --- PASS: TestExec/context_timed_out (1.00s)
    ...
PASS
ok      github.com/canonical/matter-snap-testing/utils  2.118s