kill

How to kill my own Activity - the hard way

陌路散爱 提交于 2019-12-04 07:48:46
问题 So I have my Activity, and on pressing a "Quit" button I call Activity.finish(). This effectively closes my application. The problem: The Dalvik-process of my application is still hanging around as a zombie in background. It seems like this is normal as other applications do the same. Even The hello-world example hangs around in memory.. I could live with this, but unfortunatley this behaviour makes the development of my application a pain. I have a remote service connected to my Activity,

Why number 9 in kill -9 command in unix? [closed]

若如初见. 提交于 2019-12-04 07:34:00
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 months ago . I understand it's off topic, I couldn't find anywhere online and I was thinking maybe programming gurus in the community might know this. I usually use kill -9 pid to kill the job. I always wondered the origin of 9. I looked it up online, and it says "9 Means KILL signal that is not catchable or ignorable. In

Gracefully closing a process in a remote Session

安稳与你 提交于 2019-12-04 05:29:29
问题 I'm currently working on a little PowerShell Script to reset a users Outlook Profile on a remote machine. Before the necessary profile stuff can be done I want to check if Outlook is already running on the remote machine and, if it is, stop it gracefully. I don't want to kill the process so it can do its necessary clean-up and syncing. When I connect to the machine with an Administrative User and execute the following commands: Enter-PSSession $remoteMachine $outlookProcess = Get-Process

timeout or close when process is finished

柔情痞子 提交于 2019-12-04 05:20:17
问题 I have a X.exe program that takes about 2-6 hours to finish. Exact time is unknown, but I'd like to implement a threshold of 6.5 or 7 hours. If this program does not return any value by this amount of time, it will be killed. How do I implement this using batch *.bat files? Here is what I had so far: a timer bat1.bat and an actual bat2.bat . bat1.bat: start cmd /C bat2.bat & timeout /t 25200 & taskkill /im X.exe /f bat2.bat: cd blah bat1.bat The problem with this approach is that only after

How to limit program's execution time when using subprocess?

独自空忆成欢 提交于 2019-12-04 04:54:12
I want to use subprocess to run a program and I need to limit the execution time. For example, I want to kill it if it runs for more than 2 seconds. For common programs, kill() works well. But if I try to run /usr/bin/time something , kill() can’t really kill the program. My code below seems doesn’t work well. The program is still running. import subprocess import time exec_proc = subprocess.Popen("/usr/bin/time -f \"%e\\n%M\" ./son > /dev/null", stdout = subprocess.PIPE, stderr = subprocess.STDOUT, shell = True) max_time = 1 cur_time = 0.0 return_code = 0 while cur_time <= max_time: if exec

Automating Killall then Killall level 9

旧城冷巷雨未停 提交于 2019-12-04 04:42:56
问题 Sometimes I want to killall of a certain process, but running killall doesn't work. So when I try to start the process again, it fails because the previous session is still running. Then I have to tediously run killall -9 on it. So to simplify my life, I created a realkill script and it goes like this: PIDS=$(ps aux | grep -i "$@" | awk '{ print $2 }') # Get matching pid's. kill $PIDS 2> /dev/null # Try to kill all pid's. sleep 3 kill -9 $PIDS 2> /dev/null # Force quit any remaining pid's. So

SQL: Interrupting a query

你说的曾经没有我的故事 提交于 2019-12-04 04:07:37
I've worked on a project using a proprietary non-SQL DB where queries could be interrupted and in the codebase there were quite some spots where that functionnality was used and made perfect sense (for example to stop a long running query that gets cancelled by the user, or when a more recent query takes place and renders the previous query obsolete, etc.) and I realized I never really saw that kind of "interrupted queries" previously and thought it could make a good SO question (several questions, but they're all related to exactly the same thing): can SQL queries be interrupted? is this part

programmatically kill a process in vista/windows 7 in C#

可紊 提交于 2019-12-03 18:01:58
问题 I want to kill a process programmatically in vista/windows 7 (I'm not sure if there's significant problems in the implementation of the UAC between the two to make a difference). Right now, my code looks like: if(killProcess){ System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcessesByName("MyProcessName"); // Before starting the new process make sure no other MyProcessName is running. foreach (System.Diagnostics.Process p in process) { p.Kill(); } myProcess = System

Python: when to use pty.fork() versus os.fork()

自古美人都是妖i 提交于 2019-12-03 16:16:50
问题 I'm uncertain whether to use pty.fork() or os.fork() when spawning external background processes from my app. (Such as chess engines) I want the spawned processes to die if the parent is killed, as with spawning apps in a terminal. What are the ups and downs between the two forks? 回答1: The child process created with os.fork() inherits stdin/stdout/stderr from parent process, while the child created with pty.fork() is connected to new pseudo terminal. You need the later when you write a

Can I detect when my service is killed by “Advanced Task Killer”

核能气质少年 提交于 2019-12-03 13:56:05
My app runs a geolocalisation service that the user can active or disactive by a toggleButton. To check the status of the service, I write a boolean in the Shared Preferences. I listen the beginning of the service and the end of it thanks to the onDestroy() of my service. My problem is that: When the user kill the service with the "advanced task killer", I can't know that the service is killed, the onDestroy is not called ! How can I deal with that? Thanks for your help. Florent When a process is killed (using ATK or android's own force stop button, or the function here ), it is immediately