Skip to content

Commit

Permalink
utils.RunUnderSystemdScope(): always close Conn
Browse files Browse the repository at this point in the history
Make sure we close our private connection to the bus, even if we're not
successful in in using it to ask systemd to move a unit's processes to a
specific control group.

[NO TESTS NEEDED]

Signed-off-by: Nalin Dahyabhai <[email protected]>
  • Loading branch information
nalind committed Aug 23, 2021
1 parent d113766 commit 02e59c6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/utils_supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error {
return err
}
}
defer conn.Close()
properties = append(properties, systemdDbus.PropSlice(slice))
properties = append(properties, newProp("PIDs", []uint32{uint32(pid)}))
properties = append(properties, newProp("Delegate", true))
Expand All @@ -54,7 +55,6 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error {
}
return err
}
defer conn.Close()

// Block until job is started
<-ch
Expand Down

0 comments on commit 02e59c6

Please sign in to comment.