MCPcopy Create free account
hub / github.com/1player/host-spawn / waitForSignals

Method waitForSignals

command.go:114–153  ·  view source on GitHub ↗

Wait for either host or DBus signals

(dbusSignals chan *dbus.Signal)

Source from the content-addressed store, hash-verified

112
113// Wait for either host or DBus signals
114func (c *Command) waitForSignals(dbusSignals chan *dbus.Signal) (int, error) {
115 hostSignals := make(chan os.Signal, 1)
116 signal.Notify(hostSignals)
117
118 for {
119 select {
120 case signal := <-hostSignals:
121 unixSignal := signal.(syscall.Signal)
122
123 if unixSignal == unix.SIGWINCH && c.pty != nil {
124 c.pty.inheritWindowSize()
125 break
126 } else if unixSignal == unix.SIGURG {
127 // Ignore runtime-generated SIGURG messages
128 // See https://github.com/golang/go/issues/37942
129 break
130 }
131
132 // Send the signal but ignore any error, as there is
133 // nothing much we can do about them
134 _ = c.signal(unixSignal)
135
136 case message := <-dbusSignals:
137 // Wait for HostCommandExited message
138 if message.Name != "org.freedesktop.Flatpak.Development.HostCommandExited" {
139 continue
140 }
141
142 waitStatus := message.Body[1].(uint32)
143 status, exited := interpretWaitStatus(waitStatus)
144 if exited {
145 return status, nil
146 } else {
147 return status, errors.New("child process did not terminate cleanly")
148 }
149 }
150 }
151
152 // unreachable
153}

Callers 1

SpawnAndWaitMethod · 0.95

Calls 3

signalMethod · 0.95
interpretWaitStatusFunction · 0.85
inheritWindowSizeMethod · 0.80

Tested by

no test coverage detected