从导致问题的java进程附加到外部c++进程
Attach to external c++ process from java process causing issue
我正在尝试使用java.lang.prrocess附加C++可执行文件。构建exec的代码如下:
int main(int, char**){
std::cout << "Starting Up. . . . . " << std::endl;
std::string command;
while (command != "exit")
{
std::cin >> command;
}
return 0;
}
在调试过程中,我发现在进程的创建过程中,进程在std::cin上停止,并期望输入值,但在下一次迭代中,它会自动获取上一个"命令"std::cin值,并继续迭代"While"循环,而不会将控制权交回java进程。为什么c++可执行文件在每次迭代时都不会在std::cin处停止?我正在使用Process.getOutputStream()传递来自java的值。如果描述有任何问题,请告诉我。谢谢,托尔。
很可能没有有效的输入或模拟了某种EOF。您应该检查输入是否有错误:
while ( std::cin && command != "exit" )
{
std::cin >> command;
}
相关文章:
- boost::进程间消息队列引发错误
- 可以从外部进程[C /Windows]移动/调整Windows
- 外部进程与线程和数据处理
- 从导致问题的java进程附加到外部c++进程
- 使用SetParent将窗口嵌入外部进程的各种问题
- 是否可以从外部进程注入和执行应用程序
- QT启动外部进程(激发并忘记)
- 将外部进程的输出管道传输到正在运行的脚本C++
- C++正在执行外部进程
- 从Qt程序运行外部进程,有一些更改
- 以编程方式限制外部进程资源
- 访问外部进程的内存
- 确定外部进程的主线程id (ReadProcessMemory - Err 299)
- 使用exec/fork运行外部进程
- 执行属于其他进程的外部功能
- 绕道 外部进程中的钩子"empty"功能不起作用
- 捕获外部进程的工作目录[Qt/WinAPI]
- 我可以使用DuplicateHandle使用外部进程的句柄吗
- 在c++的同一进程空间内执行外部可执行文件
- 从外部进程以编程方式更改WxWidget滑块