Attach my own pid

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Mon Mar 21 02:53:18 EDT 2016


On Mon, 21 Mar 2016 10:33:44 +0530, Nitin Varyani said:

> Sub-task 1: Until now, parent process cannot control the pid of the forked
> child. A pid gets assigned as a sequential number by the kernel at the time
> the process is forked . I want to modify kernel in such a way that parent
> process can control the pid of the forked child.

What does controlling the pid gain you?  To what purpose?

> Sub-task 2: On Linux, you can find the maximum PID value for your system
> with the following command:
>
> $ cat /proc/sys/kernel/pid_max
>
> Suppose pid_max=2000 for a system. I want that the parent process should be
> able to assign a pid which is greater that 2000 to the forked child.

Again, why would you want to do that?

Anyhow...

echo 3000 > /proc/sys/kernel/pid_max
fork a process that gets a pid over 2000.

Done.

Note that on 32 bit systems, using a pid_max of over 32768 will cause
various things in /proc to blow up.

I suspect that you need to think harder about what problem you're actually
trying to solve here - what will you do with a controlled child PID? Why does
it even matter?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160321/f5b6fdbd/attachment-0001.bin 


More information about the Kernelnewbies mailing list