[systemd-devel] Binary launched in ExecStartPre gets killed...

Belal, Awais Awais_Belal at mentor.com
Mon Mar 4 07:25:11 PST 2013


So how do i write such a service i.e. when A starts B should be started first and when A is stopped B should be stopped as well. I am really new to this so any pointers here would be really helpful. I understand that this is a very basic question but I am very new to this...


From: Kay Sievers [kay at vrfy.org]
Sent: Monday, March 04, 2013 7:54 PM
To: Belal, Awais
Cc: systemd-devel at lists.freedesktop.org
Subject: Re: [systemd-devel] Binary launched in ExecStartPre gets killed...

On Mon, Mar 4, 2013 at 12:02 PM, Belal, Awais <Awais_Belal at mentor.com> wrote:
> I have a unit file which does something like this:
> In ExecStartPre -> Start A
> In ExecStart -> Start B
> Now the thing is B depends on A to function correctly and A is a binary
> itself. The behavior I am seeing is a little obvious but still I thought
> there might be a way around this. When the unit is started A is launched
> correctly but then after some time it gets killed with a term signal 15 and
> this happens before B is started and hence when B is launched it fails.
> Here's what my unit file looks like...
> [Unit]
> Description=B
> After=xyz.service
> [Service]
> EnvironmentFile=-/tmp/my.env
> ExecStartPre=/bin/sh -c 'echo "ADDRESS=`A --print-path`" > /tmp/my.env'
> ExecStart=/usr/bin/B
> [Install]
> WantedBy=graphical.target
> Any suggestions here would be highly appreciated.

You cannot start any longer running services in Pre, we will clean
them up forcefully. If you have two services, use two service files
and express the dependencies between them.


More information about the systemd-devel mailing list