From: varyani.nitin1@gmail.com (Nitin Varyani)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Attach my own pid
Date: Sun, 27 Mar 2016 17:01:03 +0530 [thread overview]
Message-ID: <CAKfJ7KLRHAPdH4c5_te0Gn2zgAMZ+U+vkmLyVN8H3SNW+E69fw@mail.gmail.com> (raw)
In-Reply-To: <CAKfJ7KLyDdghCqLB4gz=RGkKNsYekp0sUB4UMqCfg_AfJwtRtg@mail.gmail.com>
rather this will also suffice
if (* pid == NULL*) {
retval = -ENOMEM;
pid = alloc_pid(p->nsproxy->pid_ns);
if (!pid)
goto bad_fork_cleanup_io;
}
p->pid = pid_nr(pid);
On Sun, Mar 27, 2016 at 4:57 PM, Nitin Varyani <varyani.nitin1@gmail.com>
wrote:
> If I do the following thing:
>
> struct pid remote_struct_pid;
> remote_struct_pid.numbers[0].nr=*my_pid*;
> p = copy_process(clone_flags, stack_start, stack_size, child_tidptr,
> *remote_struct_pid*, trace, tls);
>
> and modify the copy_process function little bit (marked in BOLD), it may
> serve my objective.
>
> if (pid != &init_struct_pid *&& pid == NULL*) {
> retval = -ENOMEM;
> pid = alloc_pid(p->nsproxy->pid_ns);
> if (!pid)
> goto bad_fork_cleanup_io;
> }
>
> p->pid = pid_nr(pid);
>
> The pids by kernel are allocated in the range (RESERVED_PIDS,
> PID_MAX_DEFAULT) and I will choose *my_pid* outside this range.
> I will have to modify system calls/kernel to cater to such processes.
>
>
> On Tue, Mar 22, 2016 at 3:55 PM, Bernd Petrovitsch <
> bernd at petrovitsch.priv.at> wrote:
>
>> On Die, 2016-03-22 at 01:26 -0400, Valdis.Kletnieks at vt.edu wrote:
>> > On Mon, 21 Mar 2016 16:01:41 +0530, Nitin Varyani said:
>> >
>> > > I am running a master user-level process at Computer 1 which sends a
>> > > process context like code, data, registers, PC, etc as well as
>> *"pid"* to
>> > > slave processes running at other computers. The responsibility of the
>> slave
>> > > process is to fork a new process on order of master process and
>> attach *"pid"
>> > > *given by the master to the new process it has forked. Any system
>> call on
>> > > slave nodes will have an initial check of " Whether the process
>> belongs to
>> > > local node or to the master node?". That is, if kernel at Computer 2
>> pid of
>> > > the process is 1500
>> >
>> > None of that requires actually controlling the PID of the child.
>>
>> Well, I think that the OP wants to map the PIDs with a fixed offset per
>> host. So e.g. the local PID == 14 becomes 20014 on all other nodes.
>> At least for debugging it's easier than some random mappings;-)
>>
>> As for top post: TTBOMK there is no SysCall for doing that.
>> * Perhaps one can achieve something similar with containers - one
>> container per remote host or so (but I never used containers actively
>> myself) or (ab)use KVM (does vServer still live?) for local
>> "pseudo-VMs" (and use there the original PIDs - or so).
>> * The manual page of clone(2) doesn't reveal to me if it's possible to
>> wish for a PID.
>> * You could clone (pun not intended;-) the fork() syscall and add an
>> parameter - the PID - to it (and e.g. return -1 if it's already used).
>>
>> BTW I don't know how the rest of the kernel reacts to such artifical
>> PIDs (but you will see;-) outside the "official range".
>>
>> MfG,
>> Bernd
>> --
>> "What happens when you read some doc and either it doesn't answer your
>> question or is demonstrably wrong? In Linux, you say "Linux sucks" and
>> go read the code. In Windows/Oracle/etc you say "Windows sucks" and
>> start banging your head against the wall." - Denis Vlasenko on lkml
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160327/c09832e2/attachment-0001.html
next prev parent reply other threads:[~2016-03-27 11:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-20 9:07 Attach my own pid Nitin Varyani
2016-03-20 18:33 ` Valdis.Kletnieks at vt.edu
2016-03-21 5:03 ` Nitin Varyani
2016-03-21 6:53 ` Valdis.Kletnieks at vt.edu
2016-03-21 10:31 ` Nitin Varyani
2016-03-21 10:33 ` Nitin Varyani
2016-03-21 10:47 ` Nitin Varyani
[not found] ` <CA+aCy1G351o4w-SFKaic_o-2MDOqNN+dTNfJEQteQof8CvopCQ@mail.gmail.com>
2016-03-21 11:04 ` Nitin Varyani
2016-03-22 3:22 ` Pranay Srivastava
2016-03-22 5:26 ` Valdis.Kletnieks at vt.edu
2016-03-22 10:25 ` Bernd Petrovitsch
2016-03-27 11:27 ` Nitin Varyani
2016-03-27 11:31 ` Nitin Varyani [this message]
2016-03-22 8:08 ` Mike Krinkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKfJ7KLRHAPdH4c5_te0Gn2zgAMZ+U+vkmLyVN8H3SNW+E69fw@mail.gmail.com \
--to=varyani.nitin1@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).