镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

@yaodingyd
  • 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

Activity

  1. 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[/+] on Oct 5, 2020
  2. mmomtchev commented on Oct 12, 2020

    @mmomtchev
    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

  3. added
    child_processIssues and PRs related to the child_process subsystem.
    on Oct 16, 2020
  4. somnathpanja commented on Dec 9, 2020

    @somnathpanja

    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

  5. santigimeno commented on Dec 6, 2022

    @santigimeno
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions