Stefan Reinauer has submitted this change. ( https://review.coreboot.org/c/em100/+/47732 )
Change subject: Catch SIGTERM in addition to SIGINT ......................................................................
Catch SIGTERM in addition to SIGINT
SIGINT catches CTRL-C. However, if a user will just terminate the em100 utility by running killall without any signal argument, e.g. $ killall em100 The utility will not leave the em100 utility in a good state and and it will stop working on consecutive calls. Hence catch SIGTERM as well, to make killall calls non-lethal.
Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org Change-Id: I1299fe197240c92ceda57fa3db90ef3b41278e1a Reviewed-on: https://review.coreboot.org/c/em100/+/47732 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M em100.c 1 file changed, 5 insertions(+), 4 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/em100.c b/em100.c index 09cc490..349f102 100644 --- a/em100.c +++ b/em100.c @@ -941,15 +941,16 @@ /* Set up signal handler. This is used for two reasons: * 1) to create a way to cleanly exit trace mode. * 2) to make sure that the em100 is not left in an improper state - * when receiving SIGINT for other reasons during operation. In - * this second case, we just ignore SIGINT until em100 naturally - * terminates or receives a second signal. This is OK because the - * utility is short-running in nature. + * when receiving SIGINT/SIGTERM for other reasons during operation. + * In this second case, we just ignore the first signal until em100 + * naturally terminates or receives a second signal. This is OK + * because the utility is short-running in nature. */ signal_action.sa_handler = exit_handler; signal_action.sa_flags = 0; sigemptyset(&signal_action.sa_mask); sigaction(SIGINT, &signal_action, NULL); + sigaction(SIGTERM, &signal_action, NULL);
if (em100->hwversion == HWVERSION_EM100PRO || em100->hwversion == HWVERSION_EM100PRO_EARLY) { printf("MCU version: %d.%02d\n", em100->mcu >> 8, em100->mcu & 0xff);