kill

Automatically identify (and kill) processes with long processing time

半城伤御伤魂 提交于 2019-12-13 04:46:07
问题 I'm running a script that daily downloads, builds and checks a program I'm contributing to. The "check" part implies performing a suit of test runs and comparing results with the reference. As long as the program finishes (with or without errors), everything is OK (I mean that I can handle that). But in some cases some test run is apparently stuck in an infinite loop and I have to kill it. This is quite inconvenient for a job that's supposed to run unattended. If this happens at some point,

Kill and Sleep command Not working properly in bash script

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 04:41:14
问题 I have a bash script: #!/bin/sh for ((i=0; i<=10; i++)); do ssh "w$i" 'uptime;ps -elf|grep httpd|wc -l;free -m;mpstat' done & pid=$! sleep 3 kill -9 $pid I want to kill the ssh within the for loop , if it does not complete within 3 seconds. But my observations are, that the process is not killed and that the loop takes more than 3 seconds to kill. Can you please help me to correct my script so my script can kill the for loop process after 3 seconds? 来源: https://stackoverflow.com/questions

C++ terminate thread

烈酒焚心 提交于 2019-12-13 01:51:35
问题 I know that this question has been asked and answered many times and I know that the best way to end a thread is to use flags and exit the thread function when it is requested. This is also what I am doing at the moment, but my problem is that the thread function runs for a very Long time, so sometimes I need to wait for several hours until the thread ends. My thread function looks something like this: void threadfunction() { while(!exitRequested) { doSomeWork(); object1.doSomeWork(); object2

Why doesn't bash catch the signal from the Java's process.destroy() [duplicate]

瘦欲@ 提交于 2019-12-12 23:12:51
问题 This question already has answers here : Sending a POSIX signal from the JVM (2 answers) how can I kill a Linux process in java with SIGKILL Process.destroy() does SIGTERM (4 answers) Closed last year . A Script For Testing The script below just hangs until you press Ctrl + C , then it takes two seconds to shut down. I wrote it to investigate Java's process.destroy() #! /usr/bin/env bash # dieslowly.sh bail() { echo exiting... sleep 2 echo ...exited trap - SIGINT SIGTERM kill -- -$$ } trap

No command executed after performing kill command in shell script

和自甴很熟 提交于 2019-12-12 22:38:09
问题 Here is my shell script: #!/bin/bash PIDS=$(ps -e | grep $1 |grep -v grep| awk '{print $1}') kill -s SIGINT $PIDS echo "Done sendings signal" I am passing the name of the process as command line argument. The echo command is not getting executed, although the target processes are actually receiving the SIGINT signal and exited. Any suggestions? Update: I changed the code to: #!/bin/bash PIDS=$(ps -e |grep $1 | grep -v grep | awk '{print $1}'|grep -v $$) echo $PIDS kill -s SIGINT $PIDS echo

How to get notified when a process terminates in Windows and Linux?

冷暖自知 提交于 2019-12-12 13:22:31
问题 I want to write a program, that should be notified by O.S. whenever any running process on that OS dies. I don't want to myself poll and compare everytime if a previously existing process has died. I want my program to be alerted by OS whenever a process termination happens. How do I go about it? Some sample code would be very helpful. PS: Looking for approaches in Java/C++. 回答1: Sounds like you want PsSetCreateProcessNotifyRoutine(). See this article to get started: http://www.codeproject

Do GC pauses and kill -STOP produce the same behavior?

我只是一个虾纸丫 提交于 2019-12-12 13:16:05
问题 I'm seeing a Java client application crash in the field, and I think it's because the server it's connecting to experienced a 12 second full GC pause. However, when I try to run the client / server locally out of Eclipse and reproduce the behavior using kill -STOP and kill -CONT to simulate a GC pause on the server, I'm not able to get the client application to crash--it just spins until I do kill -CONT. I'd like to figure out if the GC pause is actually the issue (if not I'll need to dive

How to kill background process from system function call

强颜欢笑 提交于 2019-12-12 10:57:43
问题 How can I kill a background process that was executed using a system function call in C language. Like for example I have a compiled application call "fooprocess". Then I want to write a program that will execute the fooprocess application in the background using the system function, please kindly see below the code, const char app[] = "fooprocess &"; system(app); As you can see there is a "&" character so that I can run the fooprocess application in the background. How can I kill this

how to use kill SIGUSR2 in bash?

佐手、 提交于 2019-12-12 10:32:16
问题 I use iptraf to monitor the network traffic in linux, and the shell command is(make iptraf running in background): iptraf -s eth0 -f -B -L ./traffic.dat if I want to get the result, I have to stop iptraf first, so I use the shell command: kill -SIGUSR2 $pid however, I could not stop iptraf if I move these shell commands into a bash script file(net.sh), and I get an error: kill: SIGUSR2: invalid signal specification I use 'kill -l' in the script file(net.sh), and I find there is no parameter

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

吃可爱长大的小学妹 提交于 2019-12-12 08:02:18
问题 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 回答1: When a