Process Id in Unix
How can i get process id of the java program being executed in the unix environment programatically .
[109 byte] By [
javatrend] at [2007-9-30 20:14:28]

AFAIK there is no pure Java way. Once I posted a JNI implementation on this forum., but not not find it any longer. If you put up with the PID of a starter script, you can do this:java -Dpid="$$" Caveat: threads under Linux show as processes.
Another suggestion was to exec an program which outputs its parent's PID. Something like this:
#include <unistd.h>
#include <stdio.h>
int main() {
printf("%d\n",getppid());
}
This works only if exec goes directly, that is, if there is no intermediate process.