[systemd-devel] [EXTERNAL] Re: ExecStop doesn't get called when service crashes

Baskaran, Vinothkumar Vinothkumar_Baskaran at comcast.com
Wed Jun 10 03:27:19 UTC 2020


Hi Reindal,

Thanks for the inputs.

In my case, the service is successfully started. The pre-script's return status is also success. Please find the output below. Still, ExecStop doesn't get invoked. I tried replacing it with ExecStopPost, it gets invoked successfully.  But, ExecStopPost cannot be used, since it gets invoked on failed cases too. Please let me know if I need to collect more information to investigate further.

● CcspCrSsp.service - CcspCrSsp service
     Loaded: loaded (/lib/systemd/system/CcspCrSsp.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-06-07 22:19:32 UTC; 1 day 9h ago
    Process: 2621 ExecStartPre=/bin/sh -c mkdir -p /rdklogs/logs/ (code=exited, status=0/SUCCESS)
    Process: 2667 ExecStartPre=/bin/sh -c (/usr/ccsp/ccspSysConfigEarly.sh) (code=exited, status=0/SUCCESS)
    Process: 2757 ExecStart=/usr/bin/CcspCrSsp -subsys $Subsys (code=exited, status=0/SUCCESS)
   Main PID: 2767 (CcspCrSsp)
     CGroup: /system.slice/CcspCrSsp.service
             └─2767 /usr/bin/CcspCrSsp -subsys eRT.

Thanks,
Vinothkumar
-----Original Message-----
From: Reindl Harald <h.reindl at thelounge.net>
Sent: 09 June 2020 22:37
To: Baskaran, Vinothkumar <Vinothkumar_Baskaran at comcast.com>; systemd-devel at lists.freedesktop.org
Subject: [EXTERNAL] Re: [systemd-devel] ExecStop doesn't get called when service crashes



Am 09.06.20 um 18:07 schrieb Baskaran, Vinothkumar:
> I am using systemd-244 in embedded linux yocto 3.1. Here, ExecStop
> doesn’t get invoked when the process CcspCrSspis killed. However, when
> service is restarted/stopped using ‘systemctl’, it gets invoked
> successfully. The system has many services with ExecStop and it
> doesn’t gets invoked in any of them. I have pasted one of the unit file here.
> Please let me know if I am missing anything.

yes, the docs:
https://urldefense.com/v3/__https://www.freedesktop.org/software/systemd/man/systemd.service.html__;!!CQl3mcHX2A!XMPI4FzT0dPBtcTPcJHQ0uoBtgTQQGG7Jx81VeUd35HN-KqSWIh7zza7ga4FSP38Sqlii7ebRg$

ExecStop=
Note that the commands specified in ExecStop= are only executed when the service started successfully first. They are not invoked if the service was never started at all, or in case its start-up failed, for example because any of the commands specified in ExecStart=, ExecStartPre= or ExecStartPost= failed (and weren't prefixed with "-", see above) or timed out. Use ExecStopPost= to invoke commands when a service failed to start up correctly and is shut down again

ExecStopPost=
Additional commands that are executed after the service is stopped. This includes cases where the commands configured in ExecStop= were used, where the service does not have any ExecStop= defined, or where the service exited unexpectedly


More information about the systemd-devel mailing list