public kill()

in src/windowsPtyAgent.ts [155:188]


  public kill(): void {
    this._inSocket.readable = false;
    this._outSocket.readable = false;
    // Tell the agent to kill the pty, this releases handles to the process
    if (this._useConpty) {
      this._getConsoleProcessList().then(consoleProcessList => {
        consoleProcessList.forEach((pid: number) => {
          try {
            process.kill(pid);
          } catch (e) {
            // Ignore if process cannot be found (kill ESRCH error)
          }
        });
        (this._ptyNative as IConptyNative).kill(this._pty);
      });
    } else {
      (this._ptyNative as IWinptyNative).kill(this._pid, this._innerPidHandle);
      // Since pty.kill closes the handle it will kill most processes by itself
      // and process IDs can be reused as soon as all handles to them are
      // dropped, we want to immediately kill the entire console process list.
      // If we do not force kill all processes here, node servers in particular
      // seem to become detached and remain running (see
      // Microsoft/vscode#26807).
      const processList: number[] = (this._ptyNative as IWinptyNative).getProcessList(this._pid);
      processList.forEach(pid => {
        try {
          process.kill(pid);
        } catch (e) {
          // Ignore if process cannot be found (kill ESRCH error)
        }
      });
    }
    this._conoutSocketWorker.dispose();
  }