Node.js | process.title Property

The process.title property is an inbuilt application programming interface of the process module which is used to get and set the title of the process.

Syntax:

process.title

Return Value: This property returns a string value that specifies the title of the process, current value is ‘ps’.

Note: Assigning the new value to this property will modify the current value. The different platforms can impose a restriction on the maximum length of process title.

Below examples illustrate the use of process.title property in Node.js:



Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Node.js program to demonstrate the    
// process.title property
  
// Include process module
const process = require('process');
  
// Printing process.title property value
console.log("PID: " + process.pid + 
      " process title is " + process.title);

chevron_right


Output:

PID: 8852 process title is Command Prompt - node  title_1

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Node.js program to demonstrate the    
// process.title property
  
// Include process module
const process = require('process');
  
// Printing process.title property value
console.log("Before modification: PID: " + process.pid
          +" process title is " + process.title);
  
// Setting new process title value
process.title = "gekchosCustomProcess";
  
// Printing process.title value after modification
console.log("After modification: PID: " + process.pid
          + " process title is " + process.title);

chevron_right


Output:

Before modification: PID: 14012 process title is Command Prompt - node  title_2
After modification: PID: 14012 process title is gekchosCustomProcess

Note: The above program will compile and run by using the node filename.js command.

Reference: https://nodejs.org/api/process.html#process_process_title

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.