Line 1:
Line 1:
== ns_last_pid ==
== ns_last_pid ==
−
In order to restore PID, CRIU uses /proc/sys/kernel/ns_last_pid, which is available in kernel since v3.3(according to [[Upstream_kernel_commits]]). It requires CONFIG_CHECKPOINT_RESTORE to be set and it's enabled in the vast majority of distros. ns_last_pid contains the last pid that was assigned by the kernel. So, when kernel needs to assign a new one, it looks into ns_last_pid, gets last_pid and assigns last_pid+1. To restore PID, criu locks ns_last_pid, writes PID-1 and calls clone().
+
In order to restore PID, CRIU uses /proc/sys/kernel/ns_last_pid, which is available in kernel since v3.3 (according to [[Upstream_kernel_commits]]). It requires CONFIG_CHECKPOINT_RESTORE to be set and it is enabled in the vast majority of distros. ns_last_pid contains the last pid that was assigned by the kernel. So, when kernel needs to assign a new one, it looks into ns_last_pid, gets last_pid and assigns last_pid+1. To restore PID, criu locks ns_last_pid, writes PID-1 and calls clone().
+
== Example ==
== Example ==
−
Here is a simple program that shows how to set PID for forked child.
+
Here is a simple program that shows how to set PID for a forked child.
'''BEWARE! This program requires root. I don't take any responsibility for what this code might do to your system.'''( tested though =) )
'''BEWARE! This program requires root. I don't take any responsibility for what this code might do to your system.'''( tested though =) )