`try` - Last process in each pipe is checked.
(procs *[]Process, tryErr bool)
| 55 | |
| 56 | // `try` - Last process in each pipe is checked. |
| 57 | func runModeTry(procs *[]Process, tryErr bool) (exitNum int) { |
| 58 | if len((*procs)) == 0 { |
| 59 | return 1 |
| 60 | } |
| 61 | |
| 62 | for i := 0; i < len(*procs); i++ { |
| 63 | go executeProcess(&(*procs)[i]) |
| 64 | next := i + 1 |
| 65 | |
| 66 | if next == len((*procs)) || !(*procs)[next].IsMethod { |
| 67 | waitProcess(&(*procs)[i]) |
| 68 | exitNum = (*procs)[i].ExitNum |
| 69 | |
| 70 | if tryErr { |
| 71 | checkTryErr(&(*procs)[i], &exitNum) |
| 72 | } |
| 73 | |
| 74 | if next < len(*procs) { |
| 75 | if exitNum < 1 && (*procs)[next].OperatorLogicOr { |
| 76 | i++ |
| 77 | (*procs)[i].SetTerminatedState(true) |
| 78 | (*procs)[i].Stdout.Close() |
| 79 | (*procs)[i].Stderr.Close() |
| 80 | GlobalFIDs.Deregister((*procs)[i].Id) |
| 81 | (*procs)[i].State.Set(state.AwaitingGC) |
| 82 | continue |
| 83 | } |
| 84 | |
| 85 | if exitNum > 0 && !(*procs)[next].OperatorLogicOr { |
| 86 | for i++; i < len(*procs); i++ { |
| 87 | (*procs)[i].Stdout.Close() |
| 88 | (*procs)[i].Stderr.Close() |
| 89 | GlobalFIDs.Deregister((*procs)[i].Id) |
| 90 | (*procs)[i].State.Set(state.AwaitingGC) |
| 91 | } |
| 92 | return |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | } else { |
| 97 | go waitProcess(&(*procs)[i]) |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | return |
| 102 | } |
| 103 | |
| 104 | // `trypipe` - Each process in the pipeline is tried sequentially. Breaks parallelization. |
| 105 | func runModeTryPipe(procs *[]Process, tryPipeErr bool) (exitNum int) { |
no test coverage detected