kill

Kill random process with name

I want a way to kill a random process with a name (eg a random perl process). What would be the best way of doing this? I was thinkign of using something like this: ps aux | grep PROCESS-NAME to a file, then find a random line number, get the second column (process ID?) and kill that. For my use it doesn't actually need to be a ...

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

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

How can I kill child process using taskkill in a batch script?

I'm capturing the PID in a variable which I kill later IF NOT "%SERVICE_PID%" == 0 taskkill /pid %SERVICE_PID% /t /f though everytime I do this in a batch file it makes my computer restart because it kills some system process the service pid should be a user defined service launched from cmd I dont understand why it keeps making ...

Kill Event when hover off in Jquery

I've seen this somewhere before but I can't seem to find the little snippet. If I have a div that sets opacity (or animates up) on hover, but I hover off that div before its done animating, I want it to toggle back. Otherwise I hover over it a few times and I have 10+ seconds of animation/flashing to wait for. Here is my code: $("a.pr...

killing a process kills other processes

I have a shell script I wrote which does the following steps within a finite loop: I spawn a process, and wait for it to finish. If it does not finish within 40 seconds, I execute: kill -SIGTERM pid I have found sometimes, even by doing the kill -SIGTERM pid, the process doesn't respond to being killed. In this case, after an additio...

PHP on a windows machine; Start process in background then Kill process

I'm looking for the best, or any way really to start a process from php in the background so I can kill it later in the script. Right now, I'm using: shell_exec($Command); The problem with this is it waits for the program to close. I want something that will have the same effect as nohup when I execute the shell command. This will allo...

Kill other bash daemons from the same script

I am having a hell of a time trying to write a "kill all other daemon processes" function for use within a bash daemon. I do not ever want more than one daemon running at once. Any suggestions? This is what I have: #!/bin/bash doService(){ while do something sleep 15 done } kil...

Killing all thread workers when one thread found the answer (ruby)

Here is a sample program: def worker(from, to) puts "#{from}..#{to}" for i in from..to do if i == 42 puts "kill the rest of the threads" break; end puts i sleep 1 end end if __FILE__ == $0 threads = [] for i in 0..9 do threads << Thread.new { worker(i*10, i*10+10) } end threads.each { |th...

C# Process Killing

i need to write a program in c# that would just start, kill one process\exe that it is supposed to kill and enditslef. 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 HOW TO DO IT... F1! F1! ...

how to kill 2 processes in linux

I have two programs running simultaneously ( in linux ) , with one running at the background. When i press ctrl+c , the prompt returns , but the processes seem to continue.. How to kill them both ? ...

How to determine killing the application

Imagine, we have two .net applications. Application "A" starts application "B" using System.Diagnostics.Process class. Then "A" wants to kill "B" by method Process.Kill. How "B" can determine that somebody is killing him? ...

kill sessions for other machines

I've an admin and client site. Multiple users will view at client site at the same time. It is possible that I can force the users logout of my client site from admin site? I'm now using classic ASP and the In Proc session is used. Is there a way where I can kill all the sessions of the users and force them to logout? ...

Run code for a certain length of time and kill if necessary

I'm using the scripting bridge to query iTunes from my cocoa application. Sometimes iTunes pops up a window (like if an ipod needs updating etc.) and while that popup window is open I can't get any information from iTunes. So if I request information from iTunes when it's in this state my application completely locks-up until that popup ...

Killing processes from list of executable names in PowerShell

I've got a PowerShell function that's returning a list of executable names (with the file extension), and I'm trying to kill any of these if they are running, but not having much success. Here's the command I'm using: Get-Executable-Names ` | where { $_ -match ".exe" } ` | foreach { $_ -replace ".exe" } ` | foreach { ps $_ } ` | kill ...

how to run and kill processes in fedora from a java GUI

Hi , I'm working in fedora. I want to create a GUI in java , with two buttons : START and STOP. i have two processes : p1 and p2. When i click on START , the process p1 should run in the background and process p2 should run in the foreground. < in terminal , we do this by giving ./p1 & ./p2 > And when i click on STOP , both the processe...

How to kill all asynchronous processes

Suppose we have a BASH script running some commands in the background. At some time we want to kill all of them, whether they have finished their job or not. Here's an example: function command_doing_nothing () { sleep 10 echo "I'm done" } for (( i = 0; i < 3; i++ )); do command_doing_nothing & done echo "Jobs:" jobs sleep 1 ...

Failed to Kill Process in SQL 2008

I have a process with the following information, and i execute the kill process to kill this id, and it return me "Only user processes can be killed." SPID:11 Status:BACKGROUND Login:sa HostName: . BlkBy: . DBName: SAFEMIG Command:CHECKPOINT Normally, all the session to login to this server, it should have a HostName which display...

How to send a signal SIGINT from script to script ? BASH

I want to trap a signal send from Script-A.sh to Script-B.sh so in Script-A.sh i use the command (Send SIGINT to Script-B.sh) kill -2 $PID_Script-B.sh And in Script-B.sh i catch the signal and call function Clean trap 'Clean' 2 It does not work, instead the Script-B.sh is killed right away without per...

How to propagate a signal through an arborescence of scripts ? Bash

I have an arborescence of scripts which are controlled by a main one I want to trap the signal ctrl-c in the main script and propagate it to the others The other scripts should trap this signal as well ( from the main script ) and do some clean-up ... I have tried to send kill -s SIGINT to the children, but they seem they are unable ...

How to kill all subprocesses of shell?

I'm writing bash script, which does several thing. In the beginning it starts several monitor scripts, each of them runs some other tools. At the end of my main script, I would like to kill all things that spawned from my shell. So, it might looks like this: #!/bin/bash some_monitor1.sh & some_monitor2.sh & some_monitor3.sh & do_so...