Commit 3896019c authored by Ludovic Rousseau's avatar Ludovic Rousseau

Exit with EXIT_SUCCESS on shutdown to please systemd

From Jakub Jelen nice bug report:
" The pcscd daemon exits with exit code 1 when it is killed by systemd,
which confuses system thinking that there was some failure on the exit:

Sep 11 13:22:54 workstation-uefi pcscd[8750]: 08450216 pcscdaemon.c:193:signal_thread() Received signal: 15
Sep 11 13:22:54 workstation-uefi pcscd[8750]: 00000015 pcscdaemon.c:213:signal_thread() Direct suicide
Sep 11 13:22:54 workstation-uefi pcscd[8750]: 00000004 pcscdaemon.c:786:at_exit() cleaning /var/run/pcscd
Sep 11 13:22:54 workstation-uefi systemd[1]: Stopping PC/SC Smart Card Daemon...
Sep 11 13:22:54 workstation-uefi systemd[1]: pcscd.service: Main process exited, code=exited, status=1/FAILURE
Sep 11 13:22:54 workstation-uefi systemd[1]: pcscd.service: Failed with result 'exit-code'.
Sep 11 13:22:54 workstation-uefi systemd[1]: Stopped PC/SC Smart Card Daemon.

Reading through the code, it looks like it exits always with 1 (except
for the alarm) so I think we should either

- modify the shipped systemd service file to mark the exit code 1 as a
  successful exit code using SuccessExitStatus or - sign in front of
  ExecStart.
- modify the pcscd to exit "cleanly" in case of termination by systemd.

I do not have any strong opinions which way is more correct, nor the
systemd maintainers do so this is merely cosmetic issue avoiding bogus
error messages filling log files on every reboot.

Initially filled as a Fedora bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1751153 "

I implemented the second solution.

Fixes https://github.com/LudovicRousseau/PCSC/issues/70
"Unclean exit when the pcscd is killed by systemd (for example on reboot)"
parent 142bc175
......@@ -211,6 +211,7 @@ static void *signal_thread(void *arg)
if (SIGTERM == sig)
{
Log1(PCSC_LOG_INFO, "Direct suicide");
ExitValue = EXIT_SUCCESS;
at_exit();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment