简体   繁体   English

如果另一个线程导致它在Windows上崩溃,我如何延迟我的进程的破坏?

[英]How do I Delay destruction of my process if another thread causes it to crash on windows?

I am writing a DLL which is loaded by a proprietary program which is closed source and I have no control over. 我正在编写一个DLL,它由一个专有程序加载,该程序是封闭源代码,我无法控制。 I also load a Proprietary DLL which is just as obscure. 我还加载了一个专有的DLL,这同样模糊不清。 Since I sometimes have to relay commands I get through my DLLs interface to the DLL I Load with very low latency I launch a separate detached thread upon initializing my DLL and send it unformatted debug information through a lock free queue. 由于我有时必须中继命令,我通过我的DLL接口访问DLL I Load,延迟非常低我在初始化DLL时启动一个单独的分离线程,并通过无锁队列发送未格式化的调试信息。 The time consuming formating of debug output and writing to a log file is thus done asynchronously. 因此,耗时的格式化调试输出和写入日志文件是异步完成的。 The problem is that the process crashes inadvertently (which I am almost certain is no my fault) and I have no way of knowing what the last debug info was because my detached thread is killed by windows before it can write it to disk. 问题是进程无意中崩溃(我几乎肯定不是我的错),我无法知道最后的调试信息是什么,因为我的分离线程被Windows杀死之后才能将其写入磁盘。

So here is my question: 所以这是我的问题:

  • Can I delay destruction in any way if the proprietary program crashes so that my detached thread runs longer before destruction? 如果专有程序崩溃,我可以以任何方式延迟销毁,以便我的分离线程在销毁之前运行更长时间吗?
  • Would interprocess communication solve my problem by moving my detached thread to another process which windows would not kill? 进程间通信是通过将我的分离线程移动到另一个窗口不会被杀死的进程来解决我的问题吗? If so what method would you suggest (I have not worked with IPC much) 如果是这样,你会建议什么方法(我没有多少与IPC合作)
  • If I use IPC how do I know when to terminate my "debug formating process"? 如果我使用IPC,我怎么知道何时终止我的“调试格式化过程”?

I think even with IPC you would have the situation where your thread may have un-written debug information during a process fault. 我认为即使使用IPC,您也会遇到过程故障期间您的线程可能有未写入的调试信息的情况。 Presumably you don't have debugging going on all the time, so I'd think you wouldn't need a separate thread for it, just a compile-time or run-time option to enable it. 大概你没有调试一直在进行,所以我认为你不需要一个单独的线程,只需要一个编译时或运行时选项来启用它。 You might be able to SetUnhandledExceptionFilter for the process and do a few things before you terminate. 您可以为进程设置SetUnhandledExceptionFilter ,并在终止之前执行一些操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM