terminate

C++ monitor running processes in the background?

本秂侑毒 提交于 2019-12-24 11:15:00
问题 I've been trying to write a program in C++ that will monitor running processes in the background and terminate a certain one if it's detected to be running. I have written a program that will do so, however the only way I can think of to do this is to use an infinite WHILE loop that keeps checking for the program. This, as you can imagine, constantly uses CPU power and resources to be constantly looping. In task manager, you can see that most processes that are running are always using 0% of

How should I terminate a looped sub-thread in Java?

戏子无情 提交于 2019-12-24 10:37:14
问题 I need to do some clean up work when I am going to terminate a looped thread. Such as saving a buffer so I can continue later. PseudoCode: private class CalculatePI(Byte[] resume) implements Runnable{ public void Run(){ while(true){ resume=resumeCalculating(resume); } } } Thread calculator= new Thread(new CalculatePI(Byte[] resume)); Thread.sleep(200); //And now I want to kill calculator So what's the best way implement this? Use a flag: But the problem is what if resumeCalculating() takes

Terminating a subprocess with KeyboardInterrupt

会有一股神秘感。 提交于 2019-12-24 04:14:11
问题 I'm using Python to call a C++ program using the subprocess module. Since the program takes some time to run, I'd like to be able to terminate it using Ctrl+C. I've seen a few questions regarding this on StackOverflow but none of the solutions seem to work for me. What I would like is for the subprocess to be terminated on KeyboardInterrupt. This is the code that I have (similar to suggestions in other questions): import subprocess binary_path = '/path/to/binary' args = 'arguments' #

Eclipse ADT: Working but “Terminate” button greyed out…?

允我心安 提交于 2019-12-23 19:39:07
问题 I've got Eclipse with ADT installed and running. Debugging is working over both USB and TCP/IP (WiFi) including live breakpoints. I'm a seasoned firmware/software developer, just new to Android/Java, and I'm pretty impressed so far with the development environment. Basically, everything is fine - except that I cannot formally terminate a debug session. The Terminate button is visible in the Run menu but is greyed out. The Suspend and Disconnect icons are functional, just not Terminate. I've

Terminate python threads using sys.exit()

▼魔方 西西 提交于 2019-12-21 23:18:01
问题 I am looking for a way to terminate a thread by using sys.exit(). I have two functions add1() and subtract1() , which are executed by each thread t1 and t2 respectively. I want to terminate t1 after finishing add1() and t2 after finishing subtract1() . I could see that sys.exit() do that work. Is it ok to do in such way? import time, threading,sys functionLock = threading.Lock() total = 0; def myfunction(caller,num): global total, functionLock functionLock.acquire() if caller=='add1': total+

Terminate Java Midi output

我怕爱的太早我们不能终老 提交于 2019-12-20 04:15:34
问题 I wrote this short program to learn the javax.sound.midi system. This is using Java 6. The output is as expected (a series of System.out.println() strings that are triggered by Sequencer events) but the problem is, after the last sound effect, the program stays in a loop and doesn't terminate as expected. Can anyone tell how to fix this? Thanks for your help: import javax.sound.midi.MidiEvent; import javax.sound.midi.ShortMessage; import javax.sound.midi.InvalidMidiDataException; import javax

How to terminate anonymous threads in Delphi on application close?

旧城冷巷雨未停 提交于 2019-12-18 16:17:32
问题 I have a Delphi application which spawns 6 anonymous threads upon some TTimer.OnTimer event. If I close the application from the X button in titlebar Access Violation at address $C0000005 is raised and FastMM reports leaked TAnonymousThread objects. Which is the best way to free anonymous threads in Delphi created within OnTimer event with TThread.CreateAnonymousThread() method? SOLUTION which worked for me: Created a wrapper of the anonymous threads which terminates them upon being Free-ed.

Terminate subprocess in Windows, access denied

孤人 提交于 2019-12-18 04:51:14
问题 - import time import subprocess from os.path import expanduser chrome_path = expanduser('~\Local Settings\Application Data\Google\Chrome\Application\chrome.exe') proc = subprocess.Popen(chrome_path) time.sleep(4) proc.terminate() Output: WindowsError: [Error 5] Access is denied How can I kill the Chrome process? Python 2.6 on Windows XP. 回答1: what happens if you use TASKKILL /F /PID [number of process ID] ? Give it a try. Launch it through import OS 回答2: I don't know about Windows, but have

ruby timeouts and system commands

ぃ、小莉子 提交于 2019-12-17 18:48:23
问题 I have a ruby timeout that calls a system (bash) command like this.. Timeout::timeout(10) { `my_bash_command -c12 -o text.txt` } but I think that even if the ruby thread is interrupted, the actual command keeps running in the background.. is it normal? How can I kill it? 回答1: I think you have to kill it manually: require 'timeout' puts 'starting process' pid = Process.spawn('sleep 20') begin Timeout.timeout(5) do puts 'waiting for the process to end' Process.wait(pid) puts 'process finished

How to stop/terminate a python script from running?

a 夏天 提交于 2019-12-17 17:59:29
问题 I wrote a program in IDLE to tokenize text files and it starts to tokeniza 349 text files! How can I stop it? How can I stop a running Python program? 回答1: To stop your program, just press Control + C . 回答2: You can also do it if you use the exit() function in your code. More ideally, you can do sys.exit() . sys.exit() might terminate Python even if you are running things in parallel through the multiprocessing package. 回答3: If your program is running at an interactive console, pressing CTRL