Christopher Schultz wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
André,
On 11/17/2010 4:50 PM, André Warnier wrote:
I found the following trick somewhere, maybe it works for you :
When starting your JVM, use a line like
java -Dpid=$$ program.java
and in the java program using the statement System.getProperty("pid");
If it works, it's cute, and certainly a lot less overhead.
Doesn't that set the "pid" system property to the pid of the shell that
launched the JVM?
Now that you mention it, I think so too. But that may be what Leon, the OP wanted : the
top parent of the process running the JVM (and Tomcat). I suppose it would depend on what
exactly you want to do with it. What happens when you "kill" the shell which runs the JVM
which runs Tomcat ?
Another question is whether it would be possible to "delay" the interpretation of the "$$"
until such time as when the JVM looks at it.
Something like : java -Dpid='$$' ...
(is there a way to tell java to get the value of an environment variable when it starts
running ? I thought there was something of the kind. But maybe that variable is not set
then. I am a bit confused now.)
Maybe we should turn the problem around though.
If Leon wanted the PID, it was obviously to do something with it later.
What do you do with a PID ? Usually, one uses it to send a signal to a process.
And sending a signal to a process, Unix-like, is not likely to be very multi-platform in
the first place.
So maybe finding a purely Java-based alternative to do what Leon wants to do with the PID
would be more productive in the long run ?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org