RunUnderSystemdScope: Wait until scope is started before we return

We need to do this, because otherwise we will continue and exit the
pid before systemd has a chance to look at it.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
This commit is contained in:
Alexander Larsson 2017-06-20 13:05:40 +02:00
parent 72686c78b4
commit d57ad7af3d

View file

@ -69,8 +69,16 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error {
properties = append(properties, newProp("PIDs", []uint32{uint32(pid)}))
properties = append(properties, newProp("Delegate", true))
properties = append(properties, newProp("DefaultDependencies", false))
_, err = conn.StartTransientUnit(unitName, "replace", properties, nil)
return err
ch := make(chan string)
_, err = conn.StartTransientUnit(unitName, "replace", properties, ch)
if err != nil {
return err
}
// Block until job is started
<-ch
return nil
}
func newProp(name string, units interface{}) systemdDbus.Property {