kill

Kill process by name?

点点圈 提交于 2019-12-17 03:23:21
问题 I'm trying to kill a process (specifically iChat). On the command line, I use these commands: ps -A | grep iChat Then: kill -9 PID However, I'm not exactly sure how to translate these commands over to Python. 回答1: Assuming you're on a Unix-like platform (so that ps -A exists), >>> import subprocess, signal >>> p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE) >>> out, err = p.communicate() gives you ps -A 's output in the out variable (a string). You can break it down into lines and

Can i wait for a process termination that is not a child of current shell terminal?

给你一囗甜甜゛ 提交于 2019-12-14 03:52:54
问题 I have a script that has to kill a certain number of times a resource managed by a high avialability middelware. It basically checks whether the resource is running and kills it afterwards, i need the timestamp of when the proc is really killed. So i have done this code: #!/bin/bash echo "$(date +"%T,%N") :New measures Run" > /home/hassan/logs/measures.log for i in {1..50} do echo "Iteration: $i" PID=`ps -ef | grep "/home/hassan/Desktop/pcmAppBin pacemaker_app/MainController"|grep -v "grep" |

linux kill process using timeout in milliseconds

笑着哭i 提交于 2019-12-13 21:20:10
问题 I want to force terminate a program after a specified time is elapsed on linux. I found that 'timeout' util in linux can kill a program after a specified time, but it does not accept MILLISECONDS. That is, "timeout TIME ./PROGRAM" kills PROGRAM after TIME elapsed where TIME is not milliseconds but seconds. Is there a way to kill a process after some MILLISECONDS on linux SHELL ? Any comments would be appreciated. 回答1: You can do something like this: #!/bin/bash #execute command in background

Python close children when closing main process

孤人 提交于 2019-12-13 16:54:18
问题 I have have a main process that forks a number of subprocesses. I want to be able to kill these child processes off when my main process gets the kill signal. Ideally I would want to do something along the lines of: def handler(signum, frame, pid_list): log('Killing Process') for pid in pid_list: os.kill(pid, signal.SIGTERM) os.waitpid(pid, 0) # need sys.exit() if __name__ == "__main__": <code that creates child processes, pids> signal.signal(signal.SIGTERM, handler(pid_list)) But of course,

ExecuteAsync RestSharp to allow backgroundWorker CancellationPending c#

本秂侑毒 提交于 2019-12-13 16:38:07
问题 I'm new to C#, RestSharp, and threading, so heres what I'm trying to do: I have made a program that will allow me to upload photos to tumblr, and I have the uploading working so far. Now I need the stop button to work, which I believe means I must use ExecuteAsync() instead of Execute() . I also have my code put in a backgroundworker, like this: private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { if (backgroundWorker1.CancellationPending) { e.Cancel = true; MessageBox

How can I kill all shells in Unix at once?

独自空忆成欢 提交于 2019-12-13 16:05:21
问题 My Mac becomes slow over time. The reason is the huge amount of my shells, such as Bashes and Fishes. Each shell has different PID. Killing shells one by one is too cumbersome. How can I kill them at once? 回答1: Try 'killall bash' or 'killall -9 bash' if they resist that. 回答2: The killall command can kill all processes with a given name: killall bash 回答3: As per other answers, the usual command is killall . Note though that on some versions of UNIX (e.g. DEC Unix) this command literally kills

How to stop certain apps from opening at all?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 09:36:15
问题 With User's permission , I want to be able to stop certain apps from opening at certain times of the day. What I want to do is - when user clicks on an app icon, the app does not open - it just shows you a "Toast" message. Can this be done? I have researched online and cannot find a way to either do this or even fake the effect. 回答1: To actually stop the apps from launching would require your application to be signed by the same cert as the os (from the manufacturer), or to be run as root (on

open last activity when the app is killed

断了今生、忘了曾经 提交于 2019-12-13 08:58:12
问题 then in my app there are 103 activity, in sequence SplashActivity -> Menu ---> Q_001 ---> Q_002 ... (...) ..... Q_finish. in each of the activity I have a button to put exit from the app (like a home button), and a button that returns to the Menu. Now I want that if the user kills the app, and open it at another time returns to the activity that was using, I know I have to try to change the SpalshActivity The last activity you were doing, if you were not carrying out any activity to continue

Unable to understand the “Kill” program of linux [closed]

家住魔仙堡 提交于 2019-12-13 08:48:36
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Here is a very small "kill" related program .The program is executing but am unable to figure out the code.Can any one please make me

How to prevent a windows application from being killed/terminate or stop [closed]

烂漫一生 提交于 2019-12-13 08:36:19
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I have a windows c++ application which runs under the normal (non-admin) user. I want that no user should be able to close/stop/terminate this application by any means. Is there any active directory group policy available to achieve this or I need to do some programming for the