()
| 63 | } |
| 64 | |
| 65 | func ExampleCommand_Signal() { |
| 66 | cmd := com.Command{ |
| 67 | Binary: "sleep", |
| 68 | Args: []string{"3600"}, |
| 69 | Timeout: time.Second, |
| 70 | } |
| 71 | |
| 72 | err := cmd.Run(context.Background()) |
| 73 | if err != nil { |
| 74 | fmt.Println("Run err:", err) |
| 75 | |
| 76 | return |
| 77 | } |
| 78 | |
| 79 | err = cmd.Signal(os.Interrupt) |
| 80 | if err != nil { |
| 81 | fmt.Println("Signal err:", err) |
| 82 | |
| 83 | return |
| 84 | } |
| 85 | |
| 86 | exec, err := cmd.Wait() |
| 87 | fmt.Println("Wait err:", err) |
| 88 | fmt.Println("Exit code:", exec.ExitCode) |
| 89 | fmt.Println("Stdout:") |
| 90 | fmt.Println(exec.Stdout) |
| 91 | fmt.Println("Stderr:") |
| 92 | fmt.Println(exec.Stderr) |
| 93 | fmt.Println("Signal:", exec.Signal) |
| 94 | |
| 95 | // Output: |
| 96 | // Wait err: command execution signaled |
| 97 | // Exit code: -1 |
| 98 | // Stdout: |
| 99 | // |
| 100 | // Stderr: |
| 101 | // |
| 102 | // Signal: interrupt |
| 103 | } |
| 104 | |
| 105 | func ExampleCommand_WithPTY() { |
| 106 | cmd := &com.Command{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…