MCPcopy Create free account
hub / github.com/containerd/nerdctl / Wait

Method Wait

mod/tigron/internal/com/command.go:273–302  ·  view source on GitHub ↗

Wait should be called after Run(), and will return the outcome of the command execution.

()

Source from the content-addressed store, hash-verified

271
272// Wait should be called after Run(), and will return the outcome of the command execution.
273func (gc *Command) Wait() (*Result, error) {
274 gc.mutex.Lock()
275 defer gc.mutex.Unlock()
276
277 switch {
278 case gc.exec == nil:
279 return nil, ErrExecNotStarted
280 case gc.exec.err != nil:
281 return gc.result, gc.exec.err
282 case gc.result != nil:
283 return gc.result, ErrExecAlreadyFinished
284 }
285
286 // Cancel the context in any case now
287 defer gc.exec.cancel()
288
289 // Wait for the command
290 _ = gc.exec.command.Wait()
291
292 // Capture timeout and cancellation
293 select {
294 case <-gc.exec.context.Done():
295 default:
296 }
297
298 // Wrap the results and return
299 err := gc.wrap()
300
301 return gc.result, err
302}
303
304// Signal sends a signal to the command. It should be called after Run() but before Wait().
305func (gc *Command) Signal(sig os.Signal) error {

Callers 15

ExampleCommandFunction · 0.95
ExampleCommand_SignalFunction · 0.95
ExampleCommand_WithPTYFunction · 0.95
ExampleCommand_FeedFunction · 0.95
ExampleErrTimeoutFunction · 0.95
BenchmarkCommandParallelFunction · 0.95
TestFaultyDoubleRunWaitFunction · 0.95
TestFaultyRunDoubleWaitFunction · 0.95
TestFailRunFunction · 0.95
TestBasicRunWaitFunction · 0.95
TestBasicFailFunction · 0.95

Calls 2

wrapMethod · 0.95
LockMethod · 0.65

Tested by 15

ExampleCommandFunction · 0.76
ExampleCommand_SignalFunction · 0.76
ExampleCommand_WithPTYFunction · 0.76
ExampleCommand_FeedFunction · 0.76
ExampleErrTimeoutFunction · 0.76
BenchmarkCommandParallelFunction · 0.76
TestFaultyDoubleRunWaitFunction · 0.76
TestFaultyRunDoubleWaitFunction · 0.76
TestFailRunFunction · 0.76
TestBasicRunWaitFunction · 0.76
TestBasicFailFunction · 0.76