Windows和Linux中的进程终止时如何获得通知? [英] How to get notified when a process terminates in Windows and Linux?

查看:144
本文介绍了Windows和Linux中的进程终止时如何获得通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个程序,该程序应由O.S.通知.只要该OS上任何正在运行的进程死亡.

I want to write a program, that should be notified by O.S. whenever any running process on that OS dies.

如果以前存在的进程已终止,我不想每次都自己进行轮询和比较.我希望我的程序在进程终止时得到操作系统的警告.

I don't want to myself poll and compare everytime if a previously existing process has died. I want my program to be alerted by OS whenever a process termination happens.

我该怎么做?一些示例代码将非常有帮助.

How do I go about it? Some sample code would be very helpful.

PS:寻找Java/C ++中的方法.

PS: Looking for approaches in Java/C++.

推荐答案

您想要的声音

Sounds like you want PsSetCreateProcessNotifyRoutine(). See this article to get started:

http://www.codeproject.com/KB/threads/procmon.aspx

这篇关于Windows和Linux中的进程终止时如何获得通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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