Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Check process existence

Thread view: 
nkammah@yahoo.fr - 17 Apr 2006 04:12 GMT
Hi all,

I'd like to check if a specific process with a given pid exists. I went
through the archives of the mailing list and I found a message dated in
2001, with this piece of code :

Process p = Runtime.getRuntime().exec("/bin/kill -0 " + pid);
p.waitFor();
boolean alive = p.exitValue() == 0;

I tried it, but I get an IOException :

java.io.IOException: CreateProcess: \bin\kill -0 3828 error=3
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at ProcessExistence.Check.check(Check.java:10)
    at ProcessExistence.Check.main(Check.java:37)

I am using windows XP.

Any idea?

Thank you !

N.
Gordon Beaton - 17 Apr 2006 08:42 GMT
> java.io.IOException: CreateProcess: \bin\kill -0 3828 error=3
[...]   
> I am using windows XP.

Kill is a unix command. Does it exist on your XP machine?

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

nkammah@yahoo.fr - 17 Apr 2006 08:38 GMT
well, probably not ! I am definitly not familiar with unix commands. I
just copied and past the code. I guess kill doesn't exist on Xp so it
perfectly makes sense now !

Would you have any advice? any function I could look at?
Gordon Beaton - 17 Apr 2006 09:34 GMT
> I guess kill doesn't exist on Xp so it perfectly makes sense now !

Well in the post you found from 2001 (written by me I think) it *did*
say "on unix you can..."

> Would you have any advice? any function I could look at?

Someone who knows Windows or XP will have to answer that. Or ask again
in a Windows newsgroup.

If there isn't a utility that you can use with Runtime.exec(), there
may be a native API for accessing the task manager that you can use
from JNI.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.