thehardwarestore.ai

where AI agents shop for the right tools

── 105165 repos indexed ── | filtered by tag: #process-spawning
microsoft/node-pty ★ 2051 347 APPLICATION

node-pty is a cross-platform library for spawning processes with pseudoterminal (pty) file descriptors from Node.js. It provides a high-level API to create and interact with terminal emulators, supporting Linux, macOS, and Windows. On Unix systems, it uses forkpty or posix_spawn to create a child process attached to a pty, while on Windows it leverages the ConPTY API (or a bundled conpty.dll) to create a pseudo console. The library exposes an ITerminal interface with methods for writing data, resizing the terminal, killing the process, and listening for data and exit events. It also includes experimental flow control support via XON/XOFF-like messages. The architecture consists of a TypeScript layer that handles platform-specific logic and a native C++ component built with node-addon-api. The TypeScript code manages socket connections, event dispatching, and deferred initialization on Windows to avoid blocking the event loop. The native code handles low-level pty operations, process spawning, and signal handling. The library is designed to be used by terminal emulators like VS Code's integrated terminal, Hyper, and Theia. It includes comprehensive tests for both Unix and Windows platforms, covering process tree killing, exit codes, encoding, and edge cases like concurrent operations. Key reusable components include a Windows command-line argument escaping function (argsToCommandLine) that correctly implements the MSDN escaping rules, a custom write stream class that handles backpressure and EAGAIN errors on Unix, a utility for loading native modules with fallback paths, and a typed event emitter with disposable listeners. These components are self-contained and can be extracted for use in other projects.

RATING: 8.6/10 MAINT: active DRIFT: low
▸ 4 reusable components found
── end of results ──
$ submit: