terminate

Android - Perfect solution for quitting or terminating an application programmatically?

▼魔方 西西 提交于 2019-11-28 14:12:03
问题 If my app encounters a particular error, I want to end my app without any trace of it remaining in the system. I have already seen many threads on this topic, specially these two. Is quitting an application frowned upon? How to quit android application programmatically The answers are great but the proposed solutions are too tedious and/or unnecessarily complex. 回答1: Taking a cue from Neil Traft's answer in the first post above, I have found a perfect solution for such scenarios. System.exit

ruby timeouts and system commands

时间秒杀一切 提交于 2019-11-28 08:58:57
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? 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 in time' end rescue Timeout::Error puts 'process not finished in time, killing it' Process.kill('TERM', pid)

Python Process won't call atexit

独自空忆成欢 提交于 2019-11-28 06:58:46
问题 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.register def log_terminate(): # ever called? logging.debug("%s Terminated!" % self.name) while True: time.sleep(10) @atexit.register def log_exit(): logging.debug("Main process

What is the standard way to get a Rust thread out of blocking operations?

廉价感情. 提交于 2019-11-28 05:18:33
问题 Coming from Java, I am used to idioms along the lines of while (true) { try { someBlockingOperation(); } catch (InterruptedException e) { Thread.currentThread.interrupt(); // re-set the interrupted flag cleanup(); // whatever is necessary break; } } This works, as far as I know, across the whole JDK for anything that might block, like reading from files, from sockets, from a queue and even for Thread.sleep() . Reading on how this is done in Rust, I find lots of seemingly special solutions

check if thread finished its method before “killing” it c#

别来无恙 提交于 2019-11-28 02:02:56
I have 2 threads in my program. 1 is handling a GUI and the other is doing some word automation. Lets call them GUIThread and WorkerThread. The WorkerThread is looping through methods using recursion. The WorkerThread is only alive while doing the word automation and the user must be able to stop the word automation. Therefore I have implemented a "Stop" button on the GUI which simply kills/terminates the WorkerThread. However if I kill the WorkerThread while it's in the middle of a method it sometimes causes a problem in my word document (this is a longer story) and that's why I want to check

Can you track when an android application has been terminated?

你说的曾经没有我的故事 提交于 2019-11-28 01:01:33
Looked at android documentation and it appears that we don't have the ability to know when an app shuts down. Whether it was explicitly by the user or automatically by the operating system. Below is the onTerminate() documentation which is only available in the emulated scenario. public void onTerminate() Since: API Level 1 This method is for use in emulated process environments. It will never be called on a production Android device, where processes are removed by simply killing them; no user code (including this callback) is executed when doing so. Does anyone have any other approaches to

C# Process Killing

ぃ、小莉子 提交于 2019-11-27 20:09:45
I need to write a program in c# that would just start, kill one process\exe that it is supposed to kill and end itself. The process I need to kill is another C# application so it is a local user process and I know the path to the exe . First search all processes for the process you want to kill, than kill it. Process[] runningProcesses = Process.GetProcesses(); foreach (Process process in runningProcesses) { // now check the modules of the process foreach (ProcessModule module in process.Modules) { if (module.FileName.Equals("MyProcess.exe")) { process.Kill(); } } } Check out Process

IOS Getting location updates when app terminated without using significantChange

若如初见. 提交于 2019-11-27 14:08:33
I apologise for the redundancy of this topic, but in spite all the given answers, I can't identify the possibility of getting accuracyBest location updates when the app is terminated. I don't want to use monitoringSignificantChange, I want the best possible accuracy; I won't submit the app on the AppStore, so Apple restrictions are not a problem either. I have gone through these: - Location update even when app is killed/terminated - iOS update location even when app is terminated - Working with location updates when app is terminated - http://mobileoop.com/getting-location-updates-for-ios-7

How terminate child processes when parent process terminated in C#

坚强是说给别人听的谎言 提交于 2019-11-27 13:15:06
问题 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 this code doesn't work properly: var job = PInvoke.CreateJobObject(null, null); var jobli = new PInvoke.JOBOBJECT_BASIC_LIMIT_INFORMATION(); jobli.LimitFlags =

Terminate a python script from another python script

旧街凉风 提交于 2019-11-27 09:31:18
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 cool shortcuts exist to make this happen? Also, I'm working in a Windows environment. I just recently found an alternative answer here: Check to see if python script is running You could get your own PID (Process Identifier) through import os os.getpid() and to kill