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

Possibility to set process name #1052

Open
henrywood opened this issue Jul 31, 2024 · 0 comments
Open

Possibility to set process name #1052

henrywood opened this issue Jul 31, 2024 · 0 comments

Comments

@henrywood
Copy link

henrywood commented Jul 31, 2024

I would suggest the possibility of setting the process name (as seen by ps or top) of master and workers via two options to the server process:

--worker-procname "Somename [worker]"
and
--master-procname "Somename [master]"

as done in this C code below:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>
#include <errno.h>

int main(int argc, char *argv[]) {
    if (argc != 2) {
        fprintf(stderr, "Usage: %s <NewName>\n", argv[0]);
        return EXIT_FAILURE;
    }

    char *new_name = argv[1];

    // Ensure the new name is not longer than 15 characters
    if (strlen(new_name) > 15) {
        fprintf(stderr, "Error: Process name cannot be longer than 15 characters\n");
        return EXIT_FAILURE;
    }

    // Change the name of the current process
    if (prctl(PR_SET_NAME, (unsigned long)new_name, 0, 0, 0) != 0) {
        perror("prctl(PR_SET_NAME)");
        return EXIT_FAILURE;
    }

    printf("Successfully changed the name of the current process to %s\n", new_name);
    while (1) {
        sleep(1); // Keep the process running to observe the name change
    }

    return 0;
}

I thought this was what the --master-name option did, but apparently not...

(what exactly does the --master-name option do ?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant