From 5c3ade4d4966755d81be422efd22c148f6677a43 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sat, 18 Apr 2026 10:35:21 -0300 Subject: [PATCH 1/2] src: add setTitle() as alternative to direct assignment Implement process.setTitle(title) as a new function-based API for setting the process title, complementing the existing process.title property assignment pattern Fixes: https://github.com/nodejs/node/issues/62797 Signed-off-by: Jonathan Lopes --- doc/api/process.md | 27 +++++++++++++++++++ .../switches/does_not_own_process_state.js | 1 + .../switches/does_own_process_state.js | 6 +++++ src/node_process_methods.cc | 12 +++++++++ test/es-module/test-esm-process-set-title.mjs | 27 +++++++++++++++++++ test/parallel/test-setproctitle.js | 12 ++++++++- .../test-worker-unsupported-things.js | 2 +- 7 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 test/es-module/test-esm-process-set-title.mjs diff --git a/doc/api/process.md b/doc/api/process.md index 61ea3c673e5f19..25f9e708f2ad7c 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -4308,6 +4308,32 @@ Assigning a value to `process.title` might not result in an accurate label within process manager applications such as macOS Activity Monitor or Windows Services Manager. +## `process.setTitle(title)` + + + +* `title` {string} + +Sets the process title. This is equivalent to assigning a string to +[`process.title`][]. See [`process.title`][] for restrictions and platform +limitations. + +```mjs +import { setTitle } from 'node:process'; + +setTitle('my-service'); +``` + +```cjs +const { setTitle } = require('node:process'); + +setTitle('my-service'); +``` + +This function is not supported in [`Worker`][] threads. + ## `process.traceDeprecation`