Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reassigning Parent PID [duplicate]

Possible Duplicate:
process re-parenting: controlling who is the new parent

I'm writing a small tool to help me launch my helper tools (because AuthorizationExecuteWithPrivilages is horrifying to use) but when I do fork()/execve() in my NSTask-like wrapper class, it forks as a child process of the helper tool. How would I get it to fork as a child process of the originating parent (the parent of the small tool launching my helper tools)? I've tried setpgid(0, parent_pid); after the fork but it doesn't work.

like image 639
Aditya Vaidyam Avatar asked Dec 31 '25 00:12

Aditya Vaidyam


1 Answers

A child process will always have a new pid. However, you can do the exec in the parent process and thus keep the pid. This works only once tho. :-)

like image 121
ott-- Avatar answered Jan 02 '26 13:01

ott--