Discussion:
[systemd-devel] ExecStop required in service file?
Michael D. Berger
2011-11-14 15:51:55 UTC
Permalink
On my F16_64, mySrvDaemon is a tcp/ip server involving posix
threads, written in C++. mySrvDaemon.service:

[Unit]
Description=Server Service
After=syslog.target network.target

[Service]
PIDFile=/var/lock/subsys/mySrvDaemon
Type=simple
ControlGroup=cpu:/
ExecStart=/usr/sbin/mySrvDaemon --daemon
ExecStop=/bin/kill -TERM $MAINPID

[Install]
WantedBy=multi-user.target

Originally, I did not have the ExecStop line. But in
that case, shutdown hangs up near the beginning. The
only way out is to power down. BTW, the TERM signal
is intercepted by mySrvDaemon and does an immediate
exit(0).

The lockup occurs even if I do:
systemctl stop mySrvDaemon
ps -ef | grep mySrvDaemon | grep -v grep
# it seems to be gone
reboot
# lockup

So, at least in this case, the ExecStop line eems to
be required. What do you think about this?

Thanks,
Mike.

--
Michael D. Berger
***@ieee.org
http://www.rosemike.net/
Michal Schmidt
2011-11-14 16:59:35 UTC
Permalink
Post by Michael D. Berger
On my F16_64, mySrvDaemon is a tcp/ip server involving posix
[Unit]
Description=Server Service
After=syslog.target network.target
[Service]
PIDFile=/var/lock/subsys/mySrvDaemon
Type=simple
Shouldn't this be "Type=forking"? Does mySrvDaemon fork by itself or
not?
Post by Michael D. Berger
ControlGroup=cpu:/
ExecStart=/usr/sbin/mySrvDaemon --daemon
ExecStop=/bin/kill -TERM $MAINPID
[Install]
WantedBy=multi-user.target
Originally, I did not have the ExecStop line. But in
that case, shutdown hangs up near the beginning. The
only way out is to power down.
Have you tried waiting a few minutes, in case a timeout kicks in?
Post by Michael D. Berger
BTW, the TERM signal
is intercepted by mySrvDaemon and does an immediate
exit(0).
systemctl stop mySrvDaemon
ps -ef | grep mySrvDaemon | grep -v grep
# it seems to be gone
What does "systemctl status mySrvDaemon.service" say at this moment?
And "systemctl list-jobs"?

Michal
Lennart Poettering
2011-12-13 10:56:49 UTC
Permalink
Post by Michael D. Berger
On my F16_64, mySrvDaemon is a tcp/ip server involving posix
[Unit]
Description=Server Service
After=syslog.target network.target
[Service]
PIDFile=/var/lock/subsys/mySrvDaemon
Type=simple
ControlGroup=cpu:/
ExecStart=/usr/sbin/mySrvDaemon --daemon
ExecStop=/bin/kill -TERM $MAINPID
Note that systemd sends TERM to all processes of a service anyway. An
ExecStop= line like this is hence fully redundant.

Lennart
--
Lennart Poettering - Red Hat, Inc.
Michael D. Berger
2011-12-13 22:33:18 UTC
Permalink
-----Original Message-----
Sent: Tuesday, December 13, 2011 05:57
To: Michael D. Berger
Subject: Re: [systemd-devel] ExecStop required in service file?
Post by Michael D. Berger
On my F16_64, mySrvDaemon is a tcp/ip server involving posix
[Unit]
Description=Server Service
After=syslog.target network.target
[Service]
PIDFile=/var/lock/subsys/mySrvDaemon
Type=simple
ControlGroup=cpu:/
ExecStart=/usr/sbin/mySrvDaemon --daemon
ExecStop=/bin/kill -TERM $MAINPID
Note that systemd sends TERM to all processes of a service anyway. An
ExecStop= line like this is hence fully redundant.
Lennart
So if instead, I did:

ExecStop=/bin/kill -9 $MAINPID

would I get both TERM and KILL signals, or would I just get KILL?

Thanks,
Mike.
--
Michael D. Berger
***@ieee.org
http://www.rosemike.net/
Zbigniew Jędrzejewski-Szmek
2011-12-14 07:53:56 UTC
Permalink
Post by Michael D. Berger
-----Original Message-----
Sent: Tuesday, December 13, 2011 05:57
To: Michael D. Berger
Subject: Re: [systemd-devel] ExecStop required in service file?
Post by Michael D. Berger
On my F16_64, mySrvDaemon is a tcp/ip server involving posix
[Unit]
Description=Server Service
After=syslog.target network.target
[Service]
PIDFile=/var/lock/subsys/mySrvDaemon
Type=simple
ControlGroup=cpu:/
ExecStart=/usr/sbin/mySrvDaemon --daemon
ExecStop=/bin/kill -TERM $MAINPID
Note that systemd sends TERM to all processes of a service anyway. An
ExecStop= line like this is hence fully redundant.
Lennart
ExecStop=/bin/kill -9 $MAINPID
would I get both TERM and KILL signals, or would I just get KILL?
You would get both, if the process lived long enough. Normally SIGTERM
would destroy the process immediately, but it could survive if there's a
kernel problem and the process is unkillable.

Best,
Zbyszek
Lennart Poettering
2011-12-14 13:13:08 UTC
Permalink
Post by Michael D. Berger
Post by Lennart Poettering
Note that systemd sends TERM to all processes of a service anyway. An
ExecStop= line like this is hence fully redundant.
Lennart
ExecStop=/bin/kill -9 $MAINPID
would I get both TERM and KILL signals, or would I just get KILL?
Well, normally the SIGKILL would already terminate the process
unconditionally, which means the SIGTERM would not get delivered
anymore. But let's say for some reason your process manages to survive
SIGKILL, then yes, you'd first get SIGKILL, then SIGTERM, and then
SIGKILL again if the process still survives after a timeout. (i.e. if a
process doesn't react to SIGTERM we follow-up with a SIGKILL)

Lennart
--
Lennart Poettering - Red Hat, Inc.
Loading...