How to set process ID in Linux for a specific program

后端 未结 6 928
后悔当初
后悔当初 2020-12-03 01:15

I was wondering if there is some way to force to use some specific process ID to Linux to some application before running it. I need to know in advance the process ID.

6条回答
  •  借酒劲吻你
    2020-12-03 01:54

    As many already suggested you cannot set directly a PID but usually shells have facilities to know which is the last forked process ID.

    For example in bash you can lunch an executable in background (appending &) and find its PID in the variable $!. Example:

    $ lsof >/dev/null &
    [1] 15458
    $ echo $!
    15458
    

提交回复
热议问题