如何将中断键序列发送到Java进程? [英] How to send interrupt key sequence to a Java Process?

查看:86
本文介绍了如何将中断键序列发送到Java进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java Process实例及其关联流的句柄。这是一个控制台程序。我想模拟一个休息序列。在Windows上是Ctrl-C。

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.

我们正在用Java包装此控制台调试器因此可以通过IDE(Eclipse)驱动它。发送中断序列将等效于在Eclipse调试器中按暂停。

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.

推荐答案

您可能想研究< a href = http://www.latenighthacking.com/projects/2003/sendSignal/ rel = nofollow noreferrer> SendSignal 。这会将ctrl-Break发送到Java进程。我以为您的目标是引起堆栈转储,对于运行中的Java进程,这是CTRL-C(信号3或SIGQUIT)的作用?

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?

这篇关于如何将中断键序列发送到Java进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆