Re: [OT] How to obtain the id of the current process

2010-11-20 Thread Pid
On 19/11/2010 19:55, André Warnier wrote: Like that JVM's JMX port for instance ? That's not a bad idea. If JMX was configured using the new Listener in server.xml and the port set in catalina.properties, then you'd be able to find out the port number without having to parse XML etc. p

Re: [OT] How to obtain the id of the current process

2010-11-19 Thread Leon Rosenberg
On Thu, Nov 18, 2010 at 6:11 PM, André Warnier a...@ice-sa.com wrote: Christopher Schultz wrote: 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

Re: [OT] How to obtain the id of the current process

2010-11-19 Thread André Warnier
Leon Rosenberg wrote: On Thu, Nov 18, 2010 at 6:11 PM, André Warnier a...@ice-sa.com wrote: Christopher Schultz wrote: 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

Re: [OT] How to obtain the id of the current process

2010-11-19 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 André, On 11/18/2010 7:03 PM, André Warnier wrote: André Warnier wrote: Christopher Schultz wrote: You also might want to kill it. In either case, most JVMs are running on win32 or UNIX-like OSs, and they both support signals. Win32 supports

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread Pid
On 17/11/2010 22:41, André Warnier wrote: Typical Java thinking.. Sure, let's pull in another 15 classes.. Gotta use those GB of RAM for something.. Why do simple when complicated would do just as well, he ? That doesn't make sense*. Leon's trying to avoid using more RAM. The JMX method

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread André Warnier
Pid wrote: On 17/11/2010 22:41, André Warnier wrote: Typical Java thinking.. Sure, let's pull in another 15 classes.. Gotta use those GB of RAM for something.. Why do simple when complicated would do just as well, he ? That doesn't make sense*. Leon's trying to avoid using more RAM. The JMX

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread Pid
On 18/11/2010 10:47, André Warnier wrote: The justification according to which a PID is not necessarily available on every platform seems a very weak one. Quite. In which case, return a null. Enough other methods do... p 0x62590808.asc Description: application/pgp-keys signature.asc

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread Tim Funk
If you have Apr available ... you might be able to use this ... org.apache.tomcat.jni.Stdlib.getpid() // public static native int getpid(); -Tim On 11/18/2010 6:10 AM, Pid wrote: On 18/11/2010 10:47, André Warnier wrote: The justification according to which a PID is not necessarily

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread Ronald Klop
That is why my Tomcats spawn a pool of sh scripts to have them run a unix command (ImageMagick, etc.) Forking of a threaded process is very expensive on a loaded server. Unix has to suspend all threads, than fork, do a lot of housekeeping and than resume all threads. After making a pool of

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread Christopher Schultz
-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

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tim, On 11/18/2010 7:19 AM, Tim Funk wrote: If you have Apr available ... you might be able to use this ... org.apache.tomcat.jni.Stdlib.getpid() // public static native int getpid(); I was going to suggest roughly the same thing, except I

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread André Warnier
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

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 André, On 11/18/2010 12:11 PM, André Warnier wrote: 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 :

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread André Warnier
Christopher Schultz wrote: You also might want to kill it. In either case, most JVMs are running on win32 or UNIX-like OSs, and they both support signals. Win32 supports signals ? - To unsubscribe, e-mail:

Re: [OT] How to obtain the id of the current process

2010-11-18 Thread André Warnier
André Warnier wrote: Christopher Schultz wrote: You also might want to kill it. In either case, most JVMs are running on win32 or UNIX-like OSs, and they both support signals. Win32 supports signals ? Well yes, kind of, apparently :

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread Pid
On 17/11/2010 21:30, Leon Rosenberg wrote: Hi, I have a ugly issue I'm sure many people on this list already solved. For multiple purposes I need pid's of processes, to stop/start them or ensure they are running. So far nothing spectacular. To obtain the pid I have following util:

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread André Warnier
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. Credits :

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread Leon Rosenberg
Pid, Andre thanx. I will try both approaches. I will try the MX Bean first, this just seems to be more elegant ;) thank you Leon On Wed, Nov 17, 2010 at 10:50 PM, André Warnier a...@ice-sa.com wrote: I found the following trick somewhere, maybe it works for you : When starting your JVM, use a

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread Konstantin Kolinko
2010/11/18 Leon Rosenberg rosenberg.l...@gmail.com: Is there another method to obtain the process id from within the process? Of Tomcat process, or of something else? You can set $CATALINA_PID in your bin/setenv.sh, and Tomcat's PID will be written to that file. If you need it for something

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread Pid
On 17/11/2010 22:02, Konstantin Kolinko wrote: 2010/11/18 Leon Rosenberg rosenberg.l...@gmail.com: Is there another method to obtain the process id from within the process? Of Tomcat process, or of something else? You can set $CATALINA_PID in your bin/setenv.sh, and Tomcat's PID will be

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread André Warnier
Leon Rosenberg wrote: Pid, Andre thanx. I will try both approaches. I will try the MX Bean first, this just seems to be more elegant ;) Typical Java thinking.. Sure, let's pull in another 15 classes.. Gotta use those GB of RAM for something.. Why do simple when complicated would do just as

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread Konstantin Kolinko
2010/11/18 André Warnier a...@ice-sa.com: I prefer Konstantin's first suggestion. Now the question is : if Tomcat writes it's PID to that file, where does Tomcat get it from ? Look into catalina.sh echo $! $CATALINA_PID (after spawning java as a background process) BTW, from all methods

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread Leon Rosenberg
On Thu, Nov 18, 2010 at 12:00 AM, Konstantin Kolinko knst.koli...@gmail.com wrote: I like the following:  int pid = Integer.parseInt( ( new File(/proc/self)).getCanonicalFile().getName() ); doesn't work on a mac ;-( - To

Re: [OT] How to obtain the id of the current process

2010-11-17 Thread Leon Rosenberg
On Wed, Nov 17, 2010 at 11:41 PM, André Warnier a...@ice-sa.com wrote: Leon Rosenberg wrote: Pid, Andre thanx. I will try both approaches. I will try the MX Bean first, this just seems to be more elegant ;) Typical Java thinking.. Sure, let's pull in another 15 classes.. Gotta use those