[systemd-bugs] [Bug 78240] New: ExecStopPost does not execute when a forking service fails to start

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat May 3 22:08:54 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=78240

          Priority: medium
            Bug ID: 78240
          Assignee: systemd-bugs at lists.freedesktop.org
           Summary: ExecStopPost does not execute when a forking service
                    fails to start
        QA Contact: systemd-bugs at lists.freedesktop.org
          Severity: normal
    Classification: Unclassified
                OS: Linux (All)
          Reporter: sergiogiogio at ovi.com
          Hardware: x86-64 (AMD64)
            Status: NEW
           Version: unspecified
         Component: general
           Product: systemd

Hello,

ExecStopPost does not execute when a forking service fails to start.
On the other hand, ExecStopPost appropriately executes when a non-forking
service fails to start.

Version: systemd 212
+PAM -AUDIT -SELINUX -IMA -SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ +SECCOMP
-APPARMOR
(Arch Linux)

Steps to reproduce:
1- Create a .service file such as below:
------
[Unit]
Description=testExecStopPost
[Service]
Type=forking
PIDFile=/var/run/testExecStopPost.pid
ExecStart=/bin/bash -c 'false& echo $! > /var/run/testExecStopPost.pid'
ExecStopPost=/usr/bin/echo ExecStopPost ran
[Install]
WantedBy=multi-user.target
------

2- Execute the below commands:
systemctl daemon-reload
systemctl start testExecStopPost
systemctl status testExecStopPost

3- Notice that the ExecStopPost command does not execute (no 'echo' in the
log):
<date> htpc systemd[1]: Starting testExecStopPost...
<date> htpc systemd[1]: PID 20110 read from file /var/run/testExecStopPost.pid
does not exist or is a zombie.
<date> htpc systemd[1]: Failed to start testExecStopPost.
<date> htpc systemd[1]: Unit testExecStopPost.service entered failed state.

4- The issue is not reproducible with non-forking services. With non-forking
services, ExecStopPost is correctly executed even if the service fails to start
(notice the 'echo' in the logs)
------
[Service]
ExecStart=/usr/bin/false
ExecStopPost=/usr/bin/echo ExecStopPost ran
------
<date> htpc systemd[1]: Started testExecStopPost.
<date> htpc systemd[1]: testExecStopPost.service: main process exited,
code=exited, status=1/FAILURE
<date> htpc echo[20242]: ExecStopPost ran
<date> htpc systemd[1]: Unit testExecStopPost.service entered failed state.

5- Indirectly related: it would be useful to have a directive to force execute
ExecStopPost if ExecStartPre fails.
Rationale: ExecStopPost is typically used for cleanup, but if ExecStartPre
fails, there is today no way to perform this cleanup. Systematically executing
ExecStopPost is probably debatable (e.g. C++ destructors do not run if
contructors fail) so having a directive, or at worst a command to force execute
ExecStopPost would be useful.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-bugs/attachments/20140504/2e691eeb/attachment.html>


More information about the systemd-bugs mailing list