Bug 1305509

Summary: [man] systemd.service documentation on TimeoutStopSec is incorrect
Product: Red Hat Enterprise Linux 7 Reporter: Stuart Auchterlonie <sauchter>
Component: systemdAssignee: Jan Synacek <jsynacek>
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.2CC: jsynacek, lnykryn, systemd-maint-list, systemd-maint
Target Milestone: rcKeywords: ManPageChange
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-219-59.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 11:32:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1298243, 1420851, 1466365, 1473733, 1546815, 1549617, 1551061    

Description Stuart Auchterlonie 2016-02-08 12:58:49 UTC
Description of problem:

The manpage of `systemd.service` documents a behaviour of
TimeoutStopSec that is in contradiction to what systemd
actually does.

Man page states:
---
  TimeoutStopSec=
    Configures the time to wait for stop. If a service is asked to stop, but does not
    terminate in the specified time, it will be terminated forcibly via SIGTERM, and
    after another timeout of equal duration with SIGKILL
---

However the behaviour is
- SIGTERM is sent immediately on `systemctl stop <service>`
- if the service does no stop after TimeoutStopSec, SIGKILL is sent

Version-Release number of selected component (if applicable):

systemd-219-19.el7.x86_64 (RHEL-7.2)

systemd-222-14.fc23.x86_64 (Fedora 23)

How reproducible:

100%

Steps to Reproduce:
1. Create a simple service that ignores SIGTERM
------ example.c ------
#include <stdio.h>
#include <unistd.h>
#include <signal.h>

int main (int argc, char **argv) {
    signal(SIGTERM, SIG_IGN);
    sleep(300);
}
------ end example.c -----

2. Create a simple unit file
------ unit file ------
[Unit]
Description=Test service for case 01576130

[Service]
Type=simple
ExecStart=/usr/local/bin/x
TimeoutStopSec=20

------ end unit file ----
3. Start test service
4. Attach gdb to service
5. Stop the service
6. Observe the signals sent to the sample service.

Actual results:

Man page is incorrect (see description)


Expected results:

Man page documents the behaviour of systemd

Additional info:

Comment 3 Lukáš Nykrýn 2016-07-25 11:45:54 UTC
Uh, sorry it looks that we have overlooked this bug.
It is not that simple, the manual message is in fact correct, there are really three steps, but since your service does not have ExecStop than we don't have anything to wait for, so we go to second step, which is sending sigterm.

Comment 11 Jan Synacek 2018-06-18 12:49:35 UTC
https://github.com/systemd/systemd/issues/9325

Comment 12 Jan Synacek 2018-06-22 07:14:52 UTC
https://github.com/systemd/systemd/pull/9378

Comment 13 Jan Synacek 2018-06-22 11:12:55 UTC
https://github.com/lnykryn/systemd-rhel/pull/218

Comment 14 Lukáš Nykrýn 2018-06-28 07:20:18 UTC
fix merged to staging branch -> https://github.com/lnykryn/systemd-rhel/pull/218 -> post

Comment 18 errata-xmlrpc 2018-10-30 11:32:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3245