MCPcopy Index your code
hub / github.com/coder/coder / Close

Method Close

pty/pty_windows.go:196–226  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

194}
195
196func (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
228func (p *windowsProcess) waitInternal() {
229 // put this on the bottom of the defer stack since the next defer can write to p.cmdErr

Callers 1

newConPtyFunction · 0.95

Calls 4

closeConsoleNoLockMethod · 0.95
CloseMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected