()
| 194 | } |
| 195 | |
| 196 | func (p *ptyWindows) Close() error { |
| 197 | p.closeMutex.Lock() |
| 198 | defer p.closeMutex.Unlock() |
| 199 | if p.closed { |
| 200 | return nil |
| 201 | } |
| 202 | |
| 203 | // Close the pseudo console, this will also terminate the process attached |
| 204 | // to this pty. If it was created via Start(), this also unblocks close of |
| 205 | // the readers below. |
| 206 | err := p.closeConsoleNoLock() |
| 207 | if err != nil { |
| 208 | return err |
| 209 | } |
| 210 | |
| 211 | // Only set closed after the console has been successfully closed. |
| 212 | p.closed = true |
| 213 | |
| 214 | // Close the pipes ensuring that the writer is closed before the respective |
| 215 | // reader, otherwise closing the reader may block indefinitely. Note that |
| 216 | // outputWrite and inputRead are unset when we Start() a new process. |
| 217 | if p.outputWrite != nil { |
| 218 | _ = p.outputWrite.Close() |
| 219 | } |
| 220 | _ = p.outputRead.Close() |
| 221 | _ = p.inputWrite.Close() |
| 222 | if p.inputRead != nil { |
| 223 | _ = p.inputRead.Close() |
| 224 | } |
| 225 | return nil |
| 226 | } |
| 227 | |
| 228 | func (p *windowsProcess) waitInternal() { |
| 229 | // put this on the bottom of the defer stack since the next defer can write to p.cmdErr |
no test coverage detected