terminate

Windows: how can I run something in a new command window in such a way that the window closes when the process finishes or crashes?

I have a script that is supposed to sit there, happily running in a command window, spewing out data... but I want the window to close automatically when the script finishes or crashes. The script is auto-restarted by other processes and I don't want my processing machines to become polluted with unused terminals. In a pinch, I have co...

C#/.NET: Process.HasExited returns true even though process is running??

I have been observing that Process.HasExited sometimes returns true even though the process is still running. My code below starts a process with name "testprogram.exe" and then waits for it to exit. The problem is that sometimes I get thrown the exception; it seems that even though HasExited returns TRUE the process itself is still ali...

Python Process won't call atexit

I'm trying to use atexit in a Process, but unfortunately it doesn't seem to work. Here's some example code: import time import atexit import logging import multiprocessing logging.basicConfig(level=logging.DEBUG) class W(multiprocessing.Process): def run(self): logging.debug("%s Started" % self.name) @atexit.regis...

Monitor and Terminate Python script based on system resource use

What is the "right" or "best" way to monitor the system resources a python script is using and terminate it if the resource use exceeds some predetermined values. In my case memory usage is of concern. I am not asking how to measure the system resource use although I am open to suggestions. As a simple example, let's assume I have a fun...

How can I stop my application?

I have the main thread from which I start a window using invokeLater. I run my application from command line. So, when application is running I see the window and my command line is "blocked" by the application. I can stop the application either by closing the window (as a result the command line is unblocked) or by typing Ctrl-C in the...

Thread does not abort on application closing

I have an application which does some background task (network listening & reading) in separate Thread. It seems however that the Thread is not being Terminated/Aborted when I close the application (click "x" button on titlebar ;)). Is that because the main Thread routine is while(true) {...} ? What is the solution here? I was looking fo...

Terminate subprocess in Windows, access denied

- 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 Win...

How to terminate a running process in matlab ?

I have a pretty simple question: how can I terminate a running script in matlab using code, similar to using CTRL + C? I want the program to stop running if a user enters incorrect digits. ...

Do function on process close?

Say I have created a process using Process.Start();. How would I tell if it had been closed/terminated, without freezing the application. In CSharp, of course. Thanks! ...

How can I forcibly close a TcpListener

I have a service which communicates through tcpListener. Problem is when the user restarts the service - an "Address already in use" exception is thrown, and the service cannot be started for a couple of minutes or so. Is there's any way of telling the system to terminate the old connection so I can open a new one? (I can't just use ran...

Terminate a python script from another python script

I've got a long running python script that I want to be able to end from another python script. Ideally what I'm looking for is some way of setting a process ID to the first script and being able to see if it is running or not via that ID from the second. Additionally, I'd like to be able to terminate that long running process. Any co...

How to run a clean up when terminating Python script

I have a python scripts that does some jobs. I use multiprocessing.Pool to have a few workers do some commands for me. My problem is when I try to terminate the script. I would like when I press Ctrl-C, that every worker immediately cleans up it's experiment (which is some custom code, or actually even a subprocess command, not just rel...

How to know when my Android app is terminating?

I need to cancel a repeating alarm when my app terminates. The problem is I have several activities and since they can be killed at any time, how can I determine when the last activity is being shutdown so I can call my alarm canceling method? ...

Debug applicationWillTerminate method call iphone sdk

Hi all, In my application, I'm trying to cache data for which I'm saving all the objects in sqlite database in applicationWillTerminate call. This method is getting called whenever I'm pressing home button on simulator, but I want to debug the code inside the method, is it possible? Or else I'll debug the code somewhere else and use it...

How terminate child processes when parent process terminated in C#

Task: Auto kill all child processes if parent process terminate. Parent procees can be terminated not only in correct way, but also by killing in ProcessExplorer, for example. How can I do it? Similar question in С topic advice to use Job objects. How to use it in C# without exporting external DLL? I tried to use Job Objects. But th...

PHP - child process blocking SIGTERM for parent

Hi all, I'm having problems with killing parent process that have 1 child - parent is waiting for child to exit and only after that kill handler is called. When the kill handler is not installed (pcntl_signal(SIGTERM, "kill_handler")) script terminates immediately. I need that after submitting kill command to terminate parent process ...

Android: Terminate TranslateAnimation earlier and immediately start a FrameAnimation at the position where the TranslateAnimation has been terminated

Hi: Thanks for reading my post. How can I terminate TranslateAnimation before its reach the destination and immediately start a FrameAnimation at the position of which the TranslateAnimation has been terminate. What I am trying to do is to apply a translate animation on textview, and make TextView more across the screen. I can click o...

How to stop a python subprocess which is running unit tests right away? Terminate and kill not working

I have a Tkinter GUI running two threads, the main tread for the GUI and a worker thread. The worker thread creates a subprocess using the following code: myProcess = subprocess.Popen(['python', '-u', 'runTests.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) The file ru...

App terminates after viewcontroller calls the delegate to close the view.

Hi experts, here the situation: i have a viewcontroller which calls in the function "viewDidLoad" a function in the AppDelegateIphone to terminate this view. The problem is that this exception comes if i make this: splashScreen.view = nil; *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: ...

Terminate Safari or Mail

Hello there, I am quite new here so I do not know many things. And the first thing I do not know is how to Terminate any running process programmatically, e.g. taping on the button; e.g. Mail or Safari. If it is possible, do not show me the whole code, just the proper way I have to try. Thanks. ...