[systemd-devel] Allow stop jobs to be killed during shutdown

Colin Guthrie gmane at colin.guthr.ie
Mon Jan 27 04:15:54 PST 2014


[Mailing list CC'ed again]

'Twas brillig, and Andrey Borzenkov at 27/01/14 11:58 did gyre and gimble:
> В Mon, 27 Jan 2014 11:27:31 +0000
> Colin Guthrie <gmane at colin.guthr.ie> пишет:
> 
>> 'Twas brillig, and Andrey Borzenkov at 26/01/14 17:16 did gyre and gimble:
>>>>> I guess what we want is to first send SIGTERM only to the systemd
>>>>> --user process, and only after a timeout start sending SIGTERM to all
>>>>> the processes in the control group? I.e., wouldn't a ExecStop entry in
>>>>> user at .service give us the required timeout?
>>>>>
>>> Does not work. systemd sends SIGTERM as soon as ExecStop finished.
>>
>> Could you not use the same hack that apache httpd needs?
>>
>> http://pkgs.fedoraproject.org/cgit/httpd.git/tree/httpd.service#n28
>>
> 
> No.
> 
> systemd user instance needs SIGTERM to start "shutdown" procedure.
> systemd system instance does not allow SIGTERM to be sent to the
> $MAINPID only. Sending SIGTERM to all processes at the very beginning
> is wrong.

Hmm, I thought the bit I quoted which said:

> ExecStop=/bin/kill -WINCH ${MAINPID}

could be used to tell the user session to start it's shudown procedure,
but rather than -WINCH as in the httpd case, we'd just send SIGTERM here
instead.

So systemdPID1 would trigger the ExecStop (triggering the user session
shutdown) and then not do the normal round of killing due to the
KillSignal, wait for a timeout (which is quite long) and only then do a
SIGKILL (which is brutal but you'd hope the user session would have done
all it's work by then and killed as much as is humanly possible (spawned
off root processes stuck in the user's cgroup not withstanding...).

But perhaps I'm still missing something and this won't work :(

And of course as mentioned originally it would be nice to provide better
semantics to control this.

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list