<div dir="ltr">If I do the following thing:<div><br></div><div><div>struct pid remote_struct_pid;</div><div>remote_struct_pid.numbers[0].nr=<b>my_pid</b>;</div><div>p = copy_process(clone_flags, stack_start, stack_size, child_tidptr, <b>remote_struct_pid</b>, trace, tls);</div></div><div><br></div><div>and modify the copy_process function little bit (marked in BOLD), it may serve my objective.</div><div><br></div><div><div>if (pid != &init_struct_pid <b>&& pid == NULL</b>) {</div><div> retval = -ENOMEM;</div><div> pid = alloc_pid(p->nsproxy->pid_ns);</div><div> if (!pid)</div><div> goto bad_fork_cleanup_io;</div><div> }</div><div> </div><div> p->pid = pid_nr(pid);</div></div><div><br></div><div>The pids by kernel are allocated in the range (RESERVED_PIDS, PID_MAX_DEFAULT) and I will choose <b>my_pid</b> outside this range.<br></div><div>I will have to modify system calls/kernel to cater to such processes. </div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 22, 2016 at 3:55 PM, Bernd Petrovitsch <span dir="ltr"><<a href="mailto:bernd@petrovitsch.priv.at" target="_blank">bernd@petrovitsch.priv.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Die, 2016-03-22 at 01:26 -0400, <a href="mailto:Valdis.Kletnieks@vt.edu">Valdis.Kletnieks@vt.edu</a> wrote:<br>
> On Mon, 21 Mar 2016 16:01:41 +0530, Nitin Varyani said:<br>
><br>
> > I am running a master user-level process at Computer 1 which sends a<br>
> > process context like code, data, registers, PC, etc as well as *"pid"* to<br>
> > slave processes running at other computers. The responsibility of the slave<br>
> > process is to fork a new process on order of master process and attach *"pid"<br>
> > *given by the master to the new process it has forked. Any system call on<br>
> > slave nodes will have an initial check of " Whether the process belongs to<br>
> > local node or to the master node?". That is, if kernel at Computer 2 pid of<br>
> > the process is 1500<br>
><br>
> None of that requires actually controlling the PID of the child.<br>
<br>
</span>Well, I think that the OP wants to map the PIDs with a fixed offset per<br>
host. So e.g. the local PID == 14 becomes 20014 on all other nodes.<br>
At least for debugging it's easier than some random mappings;-)<br>
<br>
As for top post: TTBOMK there is no SysCall for doing that.<br>
* Perhaps one can achieve something similar with containers - one<br>
container per remote host or so (but I never used containers actively<br>
myself) or (ab)use KVM (does vServer still live?) for local<br>
"pseudo-VMs" (and use there the original PIDs - or so).<br>
* The manual page of clone(2) doesn't reveal to me if it's possible to<br>
wish for a PID.<br>
* You could clone (pun not intended;-) the fork() syscall and add an<br>
parameter - the PID - to it (and e.g. return -1 if it's already used).<br>
<br>
BTW I don't know how the rest of the kernel reacts to such artifical<br>
PIDs (but you will see;-) outside the "official range".<br>
<br>
MfG,<br>
Bernd<br>
<span class="HOEnZb"><font color="#888888">--<br>
"What happens when you read some doc and either it doesn't answer your<br>
question or is demonstrably wrong? In Linux, you say "Linux sucks" and<br>
go read the code. In Windows/Oracle/etc you say "Windows sucks" and<br>
start banging your head against the wall." - Denis Vlasenko on lkml<br>
<br>
<br>
</font></span></blockquote></div><br></div>