kill

Kill all Internet Explorer processes that have been running for more than 5 minutes using Powershell

拈花ヽ惹草 提交于 2019-12-10 21:07:03
问题 I would like to kill all Internet Explorer processes that have been running more than 5 minutes. This has to be a command in one line using Powershell v1.0. 回答1: Another way: get-process iexplore | ? { ([DateTime]::Now - $_.StartTime).TotalSeconds -gt 300 } | stop-process 回答2: Get-Process iexplore -ErrorAction SilentlyContinue | Where-Object { $_.StartTime -and (Get-Date).AddMinutes(-5) -gt $_.StartTime } | Stop-Process 回答3: At least at powershell v2 following command should stop all IE

Kill a process from perl script

[亡魂溺海] 提交于 2019-12-10 20:18:00
问题 I am trying to kill a process by name which i will pass as a variable to a system command. Below is what i have: my $processName=$ARGV[0]; print "$processName\n"; system(q/kill -9 `ps -ef | grep '$processName' | grep -v grep | awk '{print $2}'`/); The above script throws an error: kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] However, if i directly enter the process name inside the system command, it works. Can someone help me on this? 回答1: One

perl - child process signaling parent

亡梦爱人 提交于 2019-12-10 18:54:59
问题 I have written the following piece of code to test signaling between child and parent. Ideally, when the child gives a SIGINT to parent the parent should come back in the new iteration and wait for user input. This I have observed in perl 5.8, but in perl 5.6.1(which I am asked to use) the parent is actually "killed". There is no next iteration. my $parent_pid = $$; $pid = fork(); if($pid == 0) { print "child started\n"; kill 2, $parent_pid; } else { while(1) { eval { $SIG{INT} = sub{die

Kill subprocess.call after KeyboardInterrupt

一个人想着一个人 提交于 2019-12-10 18:32:47
问题 I need to stop a process created using subprocess.call in Python when I get a Keyboard Interrupt (ctrl-c) The issue is p doesn't get a value assigned to it till it finishes execution p = subprocess.call(cmd) So I cant use os.kill to kill that. Also, can't use shell=True because reasons. What I would like to do is : try: p = subprocess.call(cmd) except KeyboardInterrupt: os.kill(p.pid,signal.SIGTERM) sys.exit('exited after ctrl-c') 回答1: p is just an integer ( .returncode ) and therefore there

Can't compile a program that calls tgkill

廉价感情. 提交于 2019-12-10 18:17:48
问题 I'm trying to write a program that uses tgkill to send a signal to a specific thread, but whenever I compile it with gcc I get an error about an undefined reference to 'tgkill'. I tried compiling with -lpthread but it didn't help. I've googled and googled and can't come up with any answers. How do I get it to compile?? 回答1: From the tgkill() manpage: Glibc does not provide wrappers for these system calls; call them using syscall(2). 回答2: You might want to use something like this instead. tgid

using C# to close Google chrome incognito windows only

余生颓废 提交于 2019-12-10 18:04:21
问题 I wanted to create a small program to close google incogneto windows. I have the code to kill ALL chrome windows but im not sure how to isolate just the incognito windows existing code: Process[] proc = Process.GetProcessesByName("MyApp"); foreach (Process prs in proc) { prs.Kill(); } 回答1: I played around with this a little but didn't have complete success. I was able to determine which windows were incognito, and from there, technically kill the process. However, it appears the chrome

Can I force Perl Devel::Cover to generate a coverage report if I killed the build testcover process before it was finished?

淺唱寂寞╮ 提交于 2019-12-10 17:27:15
问题 If I am able to start up Devel::Cover successfully and it starts to collect data in the cover_db directory, can I then kill the process and then after the fact get Devel::Cover or some other utility to process those binary Devel::Cover run files and structure files into the HTML coverage report? To ask the question another way ... Can I use Devel::Cover to get a coverage report for a process that I am unable to stop, other than by killing the process? This question is related to: How do I get

Ubuntu Java: Find a specific program's pid and kill the program

做~自己de王妃 提交于 2019-12-10 13:54:25
问题 I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks 回答1: You might try ps -aux | grep foobar for getting the pid, then issuing the kill command against it, alternatively you might want to use pkill foobar , in both cases foobar being the name of the app you want to terminate. 回答2: pid's for java processes -e.g ps -aux | grep

Continue service when app is killed

不打扰是莪最后的温柔 提交于 2019-12-10 12:18:05
问题 I have an activity with two buttons (ON and OFF): when I click the ON button a service starts. When I click the OFF botton the service stops. Now, my service does not have problems apart from when I kill the app from "Recent Apps" because in this circumstance the service restarts. I don't want that it restarts but I want that it continues working. The service is a START_STICKY. This is my "service" code: @Override public void onCreate() { // TODO Auto-generated method stub myServiceReceiver =

best way to close hosted process

↘锁芯ラ 提交于 2019-12-10 09:42:05
问题 I have process A that starts process B. they communicate in WCF (IAsyncResult APM Pattern), A is client B is service. When Process A dies, i need to close B. I am sending process A id as arg to process b and he does: Process.GetProcessById(processId).WaitForExit(); This is working fine. My question is how to kill process b properly if process a dies ? I tried all the following: Process.GetCurrentProcess().Close(); Process.GetCurrentProcess().Dispose(); Application.Exit(); > its a guiless