Cross-platform, multi-runtime library to set the process name visible in system monitoring tools (top, ps, htop, Activity Monitor, Task Manager, etc.).
- Multi-runtime support: Works with Node.js, Bun, and Deno
- Cross-platform: Supports Linux, macOS, and Windows
- Zero dependencies: Pure JavaScript with optional FFI for enhanced Linux support
- TypeScript support: Full type definitions included
- Comprehensive API: Async and sync versions, getters, and capability detection
# npm
npm install set-process-name
# bun
bun add set-process-name
# deno
deno add jsr:@link-foundation/set-process-nameimport { setProcessName } from 'set-process-name';
// Set the process name
await setProcessName('my-app');
// Now 'my-app' appears in top, ps, htop instead of 'node' or 'bun'Sets the process name visible in system monitoring tools.
import { setProcessName } from 'set-process-name';
const result = await setProcessName('my-service');
console.log(result);
// {
// success: true,
// processTitle: true, // process.title was set successfully
// prctl: true, // prctl was called successfully (Linux only)
// runtime: 'node', // detected runtime
// platform: 'linux' // detected platform
// }Synchronous version. Note: On Bun runtime, prctl changes may not be applied (use async version for full functionality).
import { setProcessNameSync } from 'set-process-name';
const result = setProcessNameSync('my-service');Gets the current process name from process.title.
import { getProcessName, setProcessName } from 'set-process-name';
await setProcessName('my-app');
console.log(getProcessName()); // 'my-app'Returns information about what features are available on the current platform/runtime.
import { getCapabilities } from 'set-process-name';
const caps = getCapabilities();
console.log(caps);
// {
// canSetTitle: true, // process.title can be set
// canSetPrctl: true, // prctl is available (Linux only)
// runtime: 'node',
// platform: 'linux'
// }Detects the current JavaScript runtime.
Detects the current operating system.
- Uses
process.title(which internally usesprctlvia libuv in Node.js) - On Bun/Deno: Uses FFI to call
prctl(PR_SET_NAME, name)directly - Name is truncated to 15 characters (Linux kernel limitation for
/proc/<pid>/comm) - Process name visible in
top,ps,htop, and/proc/<pid>/comm
- Uses
process.titlewhich works via libuv in Node.js - Process name visible in Activity Monitor and
ps
- Uses
process.titlefor console title - Task Manager always shows executable name (cosmetic only)
| Runtime | process.title | prctl (Linux) |
|---|---|---|
| Node.js | ✅ | ✅ (via libuv) |
| Bun | ✅ | ✅ (via FFI) |
| Deno | ✅ | ✅ (via FFI) |
import { setProcessName, getProcessName } from 'set-process-name';
async function main() {
console.log('Before:', getProcessName()); // 'node'
await setProcessName('my-daemon');
console.log('After:', getProcessName()); // 'my-daemon'
}
main();import { setProcessName, getCapabilities } from 'set-process-name';
const caps = getCapabilities();
if (caps.canSetPrctl) {
console.log('Full Linux prctl support available');
}
const result = await setProcessName('worker-1');
if (result.success) {
console.log('Process name set successfully');
} else {
console.log('Could not set process name (non-critical)');
}#!/usr/bin/env node
import { setProcessName } from 'set-process-name';
// Set process name at startup
await setProcessName('my-cli');
// Your CLI code here...Full TypeScript support with type definitions:
import {
setProcessName,
SetProcessNameResult,
Capabilities,
Runtime,
Platform,
} from 'set-process-name';
const result: SetProcessNameResult = await setProcessName('typed-app');# Node.js
npm test
# Bun
bun test
# Deno
deno test --allow-read- JavaScript Level: Sets
process.titleandprocess.argv0 - Node.js:
process.titlesetter uses libuv which internally callsprctlon Linux - Bun/Deno on Linux: Uses FFI to call
prctl(PR_SET_NAME, name)directly - macOS/Windows: Relies on
process.titlefor best-effort support
| Feature | set-process-name | process-title | process-name |
|---|---|---|---|
| Set process name | ✅ | ✅ | ❌ |
| Linux prctl | ✅ | ❌ | ❌ |
| Node.js | ✅ | ✅ | ✅ |
| Bun | ✅ | ❌ | ❌ |
| Deno | ✅ | ❌ | ❌ |
| Zero dependencies | ✅ | ✅ | ❌ |
| TypeScript support | ✅ | ❌ | ❌ |
| Active maintenance | ✅ | ❌ | ❌ |
Unlicense - Public Domain