Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process.title behaves different on linux with node >= 12.17 from other platform #35503

Closed
yaodingyd opened this issue Oct 4, 2020 · 3 comments
Labels
child_process Issues and PRs related to the child_process subsystem.

Comments

@yaodingyd
Copy link

yaodingyd commented Oct 4, 2020

  • Version: 12.17
  • Platform: Linux 14.04.1-Ubuntu x86_64 GNU/Linux
  • Subsystem: process

What steps will reproduce the bug?

I have this following script to spin up a noop process

const childProcess = require('child_process')

const code = `
	process.title = 'noop-process';
	setInterval(() => {}, 1000 * 1000);
	console.log('ok');
`;

const subprocess = childProcess.spawn('node', ['-e', code], {
	detached: true
});

console.log(subprocess.pid)

Then run ps -p pid -o comm

On linux node > 12.17, the COMMAND shows 'node', where on MAC node with any version or linux with node <=12.16 gives COMMAND noop-process

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

It should always show COMMAND is "noop-process"

What do you see instead?

Additional information

@yaodingyd yaodingyd changed the title process.title behaves different on linux node > 12.17 from other platform process.title behaves different on linux with node >= 12.17 from other platform Oct 5, 2020
@mmomtchev
Copy link
Contributor

There are two "process titles" in Linux

  • one is the so-called command line that you see when you do ps uaxw, it comes from /proc/<pid>/cmdline and this one is still modified by process.title
  • the other one is the thread name that you see when you do ps -p <pid>, that one comes from /proc/<pid>/comm and it was broken by libuv 1.35.0 that was added in Node 12.17

This is the commit that broke it: libuv/libuv@7b28d36#diff-061ff4a1f558b9316c85e332cfe90b66b3b5b612455249bfc1bb19a24e7f28e1 , line 101

@watilde watilde added the child_process Issues and PRs related to the child_process subsystem. label Oct 16, 2020
santigimeno pushed a commit to santigimeno/libuv that referenced this issue Dec 3, 2020
The call to `uv__set_process_title()` had been accidentally removed.

Fixes: libuv#3037
PR-URL: libuv#3019
Refs: nodejs/node#35503
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
santigimeno pushed a commit to santigimeno/libuv that referenced this issue Dec 3, 2020
The call to `uv__set_process_title()` had been accidentally removed.

Fixes: libuv#3037
PR-URL: libuv#3019
Refs: nodejs/node#35503
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@somnathpanja
Copy link

Still the issue exist with normal node main process itself for version >= v12.17.0

Node: v12.20.0
OS: Ubuntu 16.04 lts

timer.js

process.title = "Foo";

var timer = function() {
    setTimeout(() => {
        let k = 0;
        for(i=0; i<40000;i++){
          k += 10;
        }
        timer();
    }, 1000);
};

timer();

> node timer.js

Running TOP Command
TOP Commans Output

JeffroMF pushed a commit to JeffroMF/libuv that referenced this issue May 16, 2022
The call to `uv__set_process_title()` had been accidentally removed.

Fixes: libuv#3037
PR-URL: libuv#3019
Refs: nodejs/node#35503
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@santigimeno
Copy link
Member

This was already fixed in libuv v1.41.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem.
Projects
None yet
Development

No branches or pull requests

5 participants