Question

I want to run a c program, on eclipse, through JAVA ProcessBuilder, now at some place I want to send termination signal to the program, the program is supposed to catch that signal and perform task that is required then terminates. Now I know how to handle signals, but how can i send signals from ProcessBuilder to my program. Any help will be appreciated!

Was it helpful?

Solution

See this question : How to send SIGINT signal from Java to an external process?

Can you send `kill -SIGINT <pid>` to the process (given that you know the process ID):

    Runtime.getRuntime().exec("kill -SIGINT 12345");

Of course, that would make for a platform-dependent solution... Potentially, you'll be able to use this tool, although it is in "sandbox mode". But it might give you an idea:

http://commons.apache.org/sandbox/runtime/

See also this related question here:

https://stackoverflow.com/questions/2950338/how-can-i-kill-a-linux-process-in-java-with-sigkill-process-destroy-does-sigte
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top