Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

402
Visualizações
Change real process name in C on Linux

I'm currently trying to change the process name of a process so I can read the more easily with htop, top, .... I want to LD_PRELOAD this code into another process so it gets renamed by an environemt variable.

I found a lot of stuff in the internet, but nothing works:

prctl(PR_SET_NAME, "Test");

This does not work because htop is not honoring the name.

Nginx setproctitle (Link) doesn't work as well, because it strips the parameters (which are needed by the process).

I tried everything I found and now I'm out of ideas.

Is this even possible in linux? And how?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Just run your program by shell script or your program through exec and pass desired name as argv[0]:

#/bin/bash
exec -a fancy_name a.out ...

or C/C++:

execl( "./a.out", "fancy_name", ... );
over 4 years ago · Santiago Trujillo Relatório

0

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define NEW_NAME "hello_world"
int main(int argc, char **argv) {
  if(strcmp(argv[0], NEW_NAME)) {
    argv[0] = NEW_NAME;
    execv("/proc/self/exe", argv);
    fputs("exec failed", stderr); 
    return 1;
  }
  while(1) // so it goes to the top
    ;
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda