move notifySocket out of signalHandler

In fact, notifySocket has no relationship to signalHandler, we
can move it out of signalHandler to make the code more clear.

Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
lifubang
2025-03-18 14:25:02 +00:00
committed by Kir Kolyshkin
parent fba5a1ec23
commit e259ae0c38
3 changed files with 26 additions and 18 deletions
+16
View File
@@ -151,6 +151,22 @@ func (s *notifySocket) run(pid1 int) error {
}
}
// forward reads systemd notifications from the container and forwards them
// to notifySocketHost.
func (s *notifySocket) forward(process *libcontainer.Process, detach bool) error {
if detach {
pid, err := process.Pid()
if err != nil {
return err
}
_ = s.run(pid)
} else {
_ = s.run(os.Getpid())
go func() { _ = s.run(0) }()
}
return nil
}
// notifyHost tells the host (usually systemd) that the container reported READY.
// Also sends MAINPID and BARRIER.
func notifyHost(client *net.UnixConn, ready []byte, pid1 int) error {