MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / HandleInput

Method HandleInput

pkg/jobmanager/jobcmd.go:180–218  ·  view source on GitHub ↗

TODO set up a single input handler loop + queue so we dont need to hold the lock but still get synchronized in-order execution

(data wshrpc.CommandJobInputData)

Source from the content-addressed store, hash-verified

178
179// TODO set up a single input handler loop + queue so we dont need to hold the lock but still get synchronized in-order execution
180func (jm *JobCmd) HandleInput(data wshrpc.CommandJobInputData) error {
181 jm.lock.Lock()
182 defer jm.lock.Unlock()
183
184 if jm.cmd == nil || jm.cmdPty == nil {
185 return fmt.Errorf("no active process")
186 }
187
188 if len(data.InputData64) > 0 {
189 inputBuf := make([]byte, base64.StdEncoding.DecodedLen(len(data.InputData64)))
190 nw, err := base64.StdEncoding.Decode(inputBuf, []byte(data.InputData64))
191 if err != nil {
192 return fmt.Errorf("error decoding input data: %w", err)
193 }
194 _, err = jm.cmdPty.Write(inputBuf[:nw])
195 if err != nil {
196 return fmt.Errorf("error writing to pty: %w", err)
197 }
198 }
199
200 if data.SigName != "" {
201 sig := unixutil.ParseSignal(data.SigName)
202 if sig != nil && jm.cmd.Process != nil {
203 err := jm.cmd.Process.Signal(sig)
204 if err != nil {
205 return fmt.Errorf("error sending signal: %w", err)
206 }
207 }
208 }
209
210 if data.TermSize != nil {
211 err := jm.setTermSize_withlock(*data.TermSize)
212 if err != nil {
213 return err
214 }
215 }
216
217 return nil
218}
219
220func (jm *JobCmd) TerminateByClosingPtyMaster() {
221 jm.lock.Lock()

Callers 1

processInputQueueMethod · 0.80

Calls 3

setTermSize_withlockMethod · 0.95
ParseSignalFunction · 0.92
WriteMethod · 0.65

Tested by

no test coverage detected