
On Tue, Jul 6, 2010 at 1:32 PM, Geoffrey Mimano <soyfactor@gmail.com> wrote:
Problem is that I need to associated the pid to individual process (gotten from Runtime.getRuntime().exec("gksu rfcomm connect 0 0B:D4:91:39:66:01");) in the java app. Now since I am using Threading ie. the Runtime.getRuntime().exec(" gksu rfcomm connect 0 0B:D4:91:39:66:01"); is being called within a thread many times for the different array of devices that I have set on my machine I have to make sure I do not kill a process that has not completed its task.
what you need to do is run rfcomm from within a shell script and invoke the shell script from java : gksu rfcomm connect 0 0B:D4:91:39:66:01 & lastpid=$! echo "${LASTPID} $! - returns the pid of the last forked process which in this case is the rfcomm process ... to check if its still running you can use pgrep or pipe-filter ps -ax ...