()
| 15 | ) |
| 16 | |
| 17 | func ExampleSupervisor_Wait() { |
| 18 | ctx := context.Background() |
| 19 | cmd := New(ctx, "cat") |
| 20 | stdin, _ := cmd.Cmd().StdinPipe() |
| 21 | stdout, _ := cmd.Cmd().StdoutPipe() |
| 22 | |
| 23 | cmd.Start() |
| 24 | stdin.Write([]byte("foo")) |
| 25 | stdin.Close() |
| 26 | |
| 27 | output, _ := io.ReadAll(stdout) |
| 28 | |
| 29 | // Must call Wait _after_ interacting with pipes |
| 30 | cmd.Wait() |
| 31 | |
| 32 | fmt.Println(string(output)) |
| 33 | // Output: |
| 34 | // foo |
| 35 | } |
| 36 | |
| 37 | func ExampleSupervisor_RunAndGetOutput() { |
| 38 | ctx := context.Background() |