diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 59931d34573e..f7db759bd987 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -4714,6 +4714,20 @@ replacing it keeps being called by [`server.listen()`][], and it will be removed in a future version of Node.js. Use [`server.listen()`][] instead of calling or overriding `_listen2`. +### DEP0209: `process.title` + + + +Type: Documentation-only + +The `process.title` property is deprecated. Use [`process.getTitle()`][] to +read the current title and [`process.setTitle()`][] to change it. + [DEP0142]: #dep0142-repl_builtinlibs [DEP0156]: #dep0156-aborted-property-and-abort-aborted-event-in-http [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf @@ -4815,7 +4829,9 @@ calling or overriding `_listen2`. [`process.exit()`]: process.md#processexitcode [`process.exitCode`]: process.md#processexitcode_1 [`process.getActiveResourcesInfo()`]: process.md#processgetactiveresourcesinfo +[`process.getTitle()`]: process.md#processgettitle [`process.mainModule`]: process.md#processmainmodule +[`process.setTitle()`]: process.md#processsettitletitle [`punycode`]: punycode.md [`readable.readableEnded`]: stream.md#readablereadableended [`request.abort()`]: http.md#requestabort diff --git a/doc/api/process.md b/doc/api/process.md index fe5ecbd3d45b..e4e86a88514f 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -4315,8 +4315,12 @@ argument to the function, to get a diff reading. +> Stability: 0 - Deprecated. Use [`process.getTitle()`][] to read the title +> and [`process.setTitle()`][] to change it. + * Type: {string} The `process.title` property returns the current process title (i.e. returns @@ -4336,6 +4340,46 @@ 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. +As an alternative to direct assignment, use [`process.setTitle()`][]. + +## `process.getTitle()` + + + +* Returns: {string} + +Returns the current process title. This is equivalent to reading +[`process.title`][]. + +## `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. + +If `title` is not a string, `setTitle()` throws a `TypeError`. This differs +from assigning to [`process.title`][], which coerces the value to a string. + +```mjs +import { setTitle } from 'node:process'; + +setTitle('my-service'); +``` + +```cjs +const { setTitle } = require('node:process'); + +setTitle('my-service'); +``` + ## `process.traceDeprecation`