destroy method

void destroy()

Destroys the PTY handle, closing the master fd and freeing native resources. This should be called when the terminal is disposed to ensure full cleanup.

Implementation

void destroy() {
  if (_isDestroyed) return;
  _isDestroyed = true;
  _bindings.pty_destroy(_handle);
  _stdoutPort.close();
  _exitPort.close();
  _outputDonePort.close();
  if (!_exitCodeCompleter.isCompleted) {
    _exitCodeCompleter.complete(_nativeExitCode ?? -1);
  }
}