0

I am trying to rename the current running process name using c programming language but getting error here the code which I had done


#include <studio.h>
#include <stdlib.h>
#include <process.h>

Int main(int argc ,char *argv[])
{
_execl(argv[0],”newname.exe”,NULL);
}

While in Linux system it works properly Suppose file name is old.exe

When we open the terminal and hit command Ps -a We are able to see ./old is running

And right now I want to change the name and keep the same pid as before

The following changes are made in file name old.c


#include <studio.h>
#include <stdlib.h>
#include <unistd.h>

Int main(int argc ,char *argv[])
{
execl(argv[0],”./newname”,NULL);
While(1)
{
}
}

While above is is running then go to terminate and hit the command Ps -a You are able to see ./newname is running with the same process

So same I have to implement on windows

rohan k
  • 1
  • 1
  • [`_execl`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/execl-wexecl?view=msvc-170) doesn't replace the process on windows, it simply launches a child process then terminates the current process – Alan Birtles Sep 08 '22 at 07:17

0 Answers0