views:

1497

answers:

1

I've got a handle to a Java Process instance and its associated streams. It's a console program. I'd like to simulate a break sequence. On Windows this is Ctrl-C. Is this possible without natives?

The reason for doing this: the console program is a command-line console itself, controlling a virtual machine for another language. The user can run another program from this console program. While a program is running, the break sequence will interrupt execution of the underlying program and cause the console program to go into debug mode.

We are Java-wrapping this console debugger so that it can be driven via an IDE (Eclipse). Sending the break sequence will be the equivalent of pressing "suspend" in the Eclipse debugger.

+2  A: 

You probably want to look into SendSignal. This will send a ctrl-Break to a Java Process. I assume your goal is to cause a stack dump, which a CTRL-C (signal 3 aka SIGQUIT) will do for a running Java process?

Eddie
@Eddie: Thanks for the tip. I updated my post to add more background info. My intent was not exactly what you described.
Ben
@Eddie: great tip! Worked like a charm!
Cd-MaN