Hi,
I am running a process using the java Runtime class like so.
Process p = Runtime.getRuntime().exec("gksu rfcomm connect 0 0B:D4:91:39:66:01");
I now want to get the process ID of process p that is returned in the above statement.
I have tried using:
Field field = p.getClass().getDeclaredField("pid");
field.setAccessible(true);
this.pid=field.getInt(p); //this.pid is an int value
System.out.println("process is running +"+pid);
but the pid that is printed does not match what I get when I run the ps tool in the shell. It is important that they match because I want to run a
Process p = Runtime.getRuntime().exec("gksu kill -9 "+pid);
when I am done with the rfcomm tool.
ALTERNATIVELY:
Someone please tell me how to send a CTRL-C signal after I have run the
Process p = Runtime.getRuntime().exec("gksu rfcomm connect 0
0B:D4:91:39:66:01");
code.
--
Mimano G. Muthondu,
Software Developer
skype : gmimano
Mobile : +254 723 615 206