Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Unable to kill pty process on Windows

Open
#437 12 comments 7 reactions 1 assignee View on GitHub

@deepak1556 is already working on this.

Since Dec 19, 2025.

Assessment

This issue has not been assessed yet.

Description

bug help wanted windows

Environment details

  • OS version: Windows 10 2004
  • Node.js version: 14.15.0
  • node-pty version: 0.9.0

Issue description

Using the simple example script below, I am unable to kill the pty process on Windows 10. However, I can successfully kill the pty process on Ubuntu with the same script and identical versions of Node.js and node-pty.

Test Script

Based on https://github.com/microsoft/node-pty/blob/master/examples/killDeepTree/index.js

var os = require('os');
var pty = require('node-pty');

var shell = process.platform === 'win32' ? 'powershell.exe' : 'bash';

var ptyProcess = pty.spawn(shell, [], {
  name: 'xterm-color',
  cols: 80,
  rows: 30,
  cwd: os.homedir(),
  env: process.env
});

ptyProcess.onData((data) => process.stdout.write(data));

ptyProcess.write('ls\r');

setTimeout(() => {
  console.log('Killing pty');
  ptyProcess.kill();
}, 1000);

Output on Windows

The script hangs on the line "Killing pty" and never returns.

PS C:\Users\Timothy\Projects\test\node-pty-test> node index.js
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Timothy> ls
...

PS C:\Users\Timothy> Killing pty
Output on Ubuntu

The script finishes and returns to a prompt in the original directory.

timothy@timothy-Virtual-Machine:~/Desktop/node-pty-test$ node index.js
ls
timothy@timothy-Virtual-Machine:~$ ls
...
timothy@timothy-Virtual-Machine:~$ Killing pty
timothy@timothy-Virtual-Machine:~/Desktop/node-pty-test$
Dominant language
TypeScript
Stars
2k
Forks
337
Avg merge
21h 58m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/node-pty

All issues in microsoft/node-pty

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.