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:

  1. open /proc/sys/kernel/ns_last_pid , fd
  2. flock lock_ex
  3. write pid-1
  4. 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

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -