How to set process ID in Linux for a specific program -
i wondering if there way force use specific process id linux application before running it. need know in advance process id.
thanks
actually, there way this. since kernel 3.3 config_checkpoint_restore set(which set in distros), there /proc/sys/kernel/ns_last_pid contains last pid generated kernel. so, if want set pid forked program, need perform these actions:
- open /proc/sys/kernel/ns_last_pid , fd
- flock lock_ex
- write pid-1
- fork
voilĂ ! child have pid wanted. also, don't forget unlock (flock lock_un) , close ns_last_pid.
you can checkout c code @ blog here.
Comments
Post a Comment