Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the process ID (PID) in Linux

Tags:

linux

process

pid

Is it possible to change the PID in Linux? If anyone know, please tell me.

Requirement: actually I want to bring up the back ground process to foreground, which is being run under the init. So if I can change the PID or parent PID of the process, I can achieve my goal.

like image 333
Pavunkumar Avatar asked Feb 25 '26 05:02

Pavunkumar


2 Answers

No, it's not possible to do such a thing on Unix. You might be able to use fork to achieve this effect, but you have to tell us what you are trying to achieve.

pid_t pid;

/* I want a new PID. */
pid fork();
if (pid == 0) {
    /* getpid() will show I've got a new PID. */
else
    _exit(0); /* Parent or check for -1 (tinfoil hat)

Obviously, like I said before, you "might" be able to use this.

like image 79
cnicutar Avatar answered Feb 27 '26 22:02

cnicutar


Short answer: No.

Long answer: pocess id's(PID) are generated by the system, and are unique, and generated when the app starts. You cannot control the way they are generated...

like image 31
Quamis Avatar answered Feb 27 '26 20:02

Quamis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!