kill

Performing equivalent of “Kill Process Tree” in C++ on windows

浪尽此生 提交于 2019-11-28 09:49:12
We have a C++ task that will fork a new process. That process in turn may have several child processes. If the task runs past an allotted time, we will want to kill that forked process. However, we don't want to orphan the processes it has spawned. We want them all to die. I have used Process Explorer and it has a "Kill Process Tree" option, similar to Windows Task Manager's "End Process Tree", so I'm guessing/assuming there is a public API to do this. Has anyone done this, or know of a reference to a public API that does? EFraim You might want to consider the "Jobs API". CreateJobObject and

How to detect a Kill Process event

懵懂的女人 提交于 2019-11-28 06:35:08
问题 In C# i using process.Kill() kill a process, at the same time in killed application how to detect this event? BTW: Application.ApplicationExit event has not been fired! 回答1: if it's a winform, you can capture the event FormClosing and check the CloseReason : None WindowsShutDown MdiFormClosing UserClosing TaskManagerClosing FormOwnerClosing ApplicationExitCall 回答2: There are no simple ways of accomplishing this, though code injecting, api hooking, and a number of other techniques could be

Run a process and kill it if it doesn't end within one hour

五迷三道 提交于 2019-11-28 05:55:27
I need to do the following in Python. I want to spawn a process (subprocess module?), and: if the process ends normally, to continue exactly from the moment it terminates; if, otherwise, the process "gets stuck" and doesn't terminate within (say) one hour, to kill it and continue (possibly giving it another try, in a loop). What is the most elegant way to accomplish this? The subprocess module will be your friend. Start the process to get a Popen object, then pass it to a function like this. Note that this only raises exception on timeout. If desired you can catch the exception and call the

How to kill a child process by the parent process?

不羁岁月 提交于 2019-11-28 05:24:34
I create a child process using a fork() . How can the parent process kill the child process if the child process cannot complete its execution within 30 seconds? I want to allow the child process to execute up to 30 seconds. If it takes more than 30 seconds, the parent process will kill it. Do you have any idea to do that? Mikola Send a SIGTERM or a SIGKILL to it: http://en.wikipedia.org/wiki/SIGKILL http://en.wikipedia.org/wiki/SIGTERM SIGTERM is polite and lets the process clean up before it goes, whereas, SIGKILL is for when it won't listen >:) Example from the shell (man page: http:/

How to call a particular method before killing a storm topology

江枫思渺然 提交于 2019-11-28 04:21:25
问题 How to call a particular method before killing a storm topology. I have created a topology in storm, I wanted to call particular method, just before topology gets killed. is there any predefined overridden or any method available to do this in storm framework. Thanks in advance:) 回答1: There is no such thing... As a workaround, you can deactivate the topology before killing it. This ensures, that Spout.deactivate() is called. If you need to call a method at bolts, use Spout.deactivate() to

Killing processes opened with popen()?

心已入冬 提交于 2019-11-28 03:34:55
问题 I'm opening a long-running process with popen(). For debugging, I'd like to terminate the process before it has completed. Calling pclose() just blocks until the child completes. How can I kill the process? I don't see any easy way to get the pid out of the resource that popen() returns so that I can send it a signal. I suppose I could do something kludgey and try to fudge the pid into the output using some sort of command-line hackery... 回答1: Well, landed on a solution: I switched back to

Service crashing and restarting

大憨熊 提交于 2019-11-27 23:22:40
There are several questions about it but I always read the same thing: "the service will be killed if the system need resources" or "you can't build an service that runs forever because the more it runs in background, more susceptible it is to the system kills it" and etc. The problem I'm facing is: My service runs fine and as it is expected, if I run my app then exit it my service is still running, but when I kill my app (by going to the "recent apps" and swype it away) the service stops. In this moment, if I go to the Settings >> aplications >> running I'll see that the service is restarting

Activity restarts on Force Close

久未见 提交于 2019-11-27 21:31:11
I have an Application with a single root Activity. I've recently had it brought to my attention that any kind of Force Close on my Activity results in it restarting and I have no idea why this might happen. If I force an uncaught exception or use the 'long back press to force close' option, they both result in the same. My only guess would have been some form of quirk relating to retained references to some part of the Activity, only I don't have any outside of some WeakReference entries at the Application level. Relevant logcat entries: 05-25 08:25:49.137: INFO/ActivityManager(18449):

How to terminate process using VBScript

穿精又带淫゛_ 提交于 2019-11-27 20:40:51
I have this VBScript code to terminate one process Const strComputer = "." Dim objWMIService, colProcessList Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'Process.exe'") For Each objProcess in colProcessList objProcess.Terminate() Next It works fine with some processes, but when it comes to any process runs under SYSTEM, it can't stop it. Is there is anything I need to add to kill the process under SYSTEM? The way I have gotten this to work

Linux C catching kill signal for graceful termination

和自甴很熟 提交于 2019-11-27 20:11:23
I have a process using sockets, database connections and the likes. It is basically a server process relaying between sensor data and a web interface, and as such it is important to ensure the application, if killed, terminates gracefully. How do I handle unexpected exceptions such as segfaults (at least for debugging) as well as kill signals so that I can close any connections and stop any threads running so that the process does not leave a mess of anything it is using? You install signal handlers to catch signals -- however in 99% of cases you just want to exit and let the Linux OS take