zephyr/soc
Marc Herbert 67f7b43136 soc: xtensa: remote-fw-service.py: fix usage without sudo
It's best practice to run as little code as possible as root (especially
when listening to network ports). When not itself running as root
already, remote-fw-service.py has always tried to invoke cavstool.py
with "sudo". Unfortunately this looks like it never worked; at least not
on Ubuntu 22 where this commit was tested. Moreover it did not fail
immediately but mysteriously timed out without any useful error message.

- The first, most obvious bug was that "sudo" does not propagate
SIGKILL (and a few other signals), see "man sudo". Compare:

```
$ sudo sleep 30 &
$ kill  $! # sudo propagates the TERM signal and sleep is terminated

$ sudo sleep 30 & sudoPID=$!
$ kill -KILL $sudoPID
$  ps  xfao pid,ppid,pgid,sid,comm | grep -C 5 -e PID -e sleep -e sudo
```

Fix this by invoking proc.terminate() first before proc.kill().
proc.terminate() is more "polite" with cavstool even when not using
sudo.

- Second issue: when signals are sent to sudo, strace shows that its
signal handler invokes `getpgid()` and then ignores signals coming from
its own process group. `man sudo` states: "sudo will not relay signals
that were sent by the command it is running...", which seems related.

`start_new_session=True` option moves sudo to a different PGID which
stops sudo from ignoring signals from its remote-fw-service.py parent.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-28 16:42:29 -04:00
..
arc ARC: Add MWDT support into qemu_arc_hs platform 2023-03-20 11:43:37 +01:00
arm soc: arm: stm32h5 new soc serie 2023-03-28 15:07:51 +02:00
arm64 soc: include: fvp_aemv8r: Define device memory as device tree node 2023-03-27 13:20:47 +00:00
mips asm: update files with <zephyr/...> include prefix 2022-05-09 12:45:29 -04:00
nios2 linker: update files with <zephyr/...> include prefix 2022-05-09 12:45:29 -04:00
posix soc: posix: inf_clock: add C++ support to NATIVE_TASK 2023-01-26 09:30:36 +01:00
riscv soc: esp32s3: add bluetooth support 2023-03-27 13:19:38 +00:00
sparc linker: update files with <zephyr/...> include prefix 2022-05-09 12:45:29 -04:00
x86 soc: x86: raptor_lake: Add GPIO support for rpl_crb 2023-03-15 22:41:53 +00:00
xtensa soc: xtensa: remote-fw-service.py: fix usage without sudo 2023-03-28 16:42:29 -04:00
Kconfig nrf52_bsim: Convert from a nRF52832 to a nRF52833 2023-01-26 09:29:18 +01:00