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:
parent
72686c78b4
commit
d57ad7af3d
1 changed files with 10 additions and 2 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue