<div dir="ltr">rather this will also suffice<div><br></div><div><div style="font-size:12.8px">if (<b> pid == NULL</b>) {</div><div style="font-size:12.8px">                 retval = -ENOMEM;</div><div style="font-size:12.8px">                 pid = alloc_pid(p-&gt;nsproxy-&gt;pid_ns);</div><div style="font-size:12.8px">                 if (!pid)</div><div style="font-size:12.8px">                         goto bad_fork_cleanup_io;</div><div style="font-size:12.8px">         }</div><div style="font-size:12.8px"> </div><div style="font-size:12.8px">         p-&gt;pid = pid_nr(pid);</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 27, 2016 at 4:57 PM, Nitin Varyani <span dir="ltr">&lt;<a href="mailto:varyani.nitin1@gmail.com" target="_blank">varyani.nitin1@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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 != &amp;init_struct_pid <b>&amp;&amp; pid == NULL</b>) {</div><div>                 retval = -ENOMEM;</div><div>                 pid = alloc_pid(p-&gt;nsproxy-&gt;pid_ns);</div><div>                 if (!pid)</div><div>                         goto bad_fork_cleanup_io;</div><div>         }</div><div> </div><div>         p-&gt;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="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 22, 2016 at 3:55 PM, Bernd Petrovitsch <span dir="ltr">&lt;<a href="mailto:bernd@petrovitsch.priv.at" target="_blank">bernd@petrovitsch.priv.at</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Die, 2016-03-22 at 01:26 -0400, <a href="mailto:Valdis.Kletnieks@vt.edu" target="_blank">Valdis.Kletnieks@vt.edu</a> wrote:<br>
&gt; On Mon, 21 Mar 2016 16:01:41 +0530, Nitin Varyani said:<br>
&gt;<br>
&gt; &gt; I am running a master user-level process at Computer 1 which sends a<br>
&gt; &gt; process context like code, data, registers, PC, etc as well as *&quot;pid&quot;* to<br>
&gt; &gt; slave processes running at other computers. The responsibility of the slave<br>
&gt; &gt; process is to fork a new process on order of master process and attach *&quot;pid&quot;<br>
&gt; &gt; *given by the master to the new process it has forked. Any system call on<br>
&gt; &gt; slave nodes will have an initial check of &quot; Whether the process belongs to<br>
&gt; &gt; local node or to the master node?&quot;. That is, if kernel at Computer 2 pid of<br>
&gt; &gt; the process is 1500<br>
&gt;<br>
&gt; 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&#39;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>
  &quot;pseudo-VMs&quot; (and use there the original PIDs - or so).<br>
* The manual page of clone(2) doesn&#39;t reveal to me if it&#39;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&#39;s already used).<br>
<br>
BTW I don&#39;t know how the rest of the kernel reacts to such artifical<br>
PIDs (but you will see;-) outside the &quot;official range&quot;.<br>
<br>
MfG,<br>
        Bernd<br>
<span><font color="#888888">--<br>
&quot;What happens when you read some doc and either it doesn&#39;t answer your<br>
question or is demonstrably wrong? In Linux, you say &quot;Linux sucks&quot; and<br>
go read the code. In Windows/Oracle/etc you say &quot;Windows sucks&quot; and<br>
start banging your head against the wall.&quot;    - Denis Vlasenko on lkml<br>
<br>
<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>