How to send custom signal to kill running process with Goland? - intellij-idea

When I run/debug Ginkgo test from Intellij Idea (with Go plugin installed), it does not shut down gracefully if I press "Stop" button.
JustBeforeEach and AfterEach functions do not get executed and process stops immediately. When I run test from console it gracefully shuts down if I press Ctrl+C. How can I make Intellij Idea/Goland to send custom signal in order to stop running process?
My gotest options are: -ginkgo.v -ginkgo.progress -ginkgo.trace -ginkgo.focus=MyTest

GoLand sends a SIGINT then follows with a SIGKILL to terminate the process. You should make your application handle either of those signals before exiting.

On a Linux/Unix OS, you can use the kill command. For example, if you want to send an interrupt signal, you would use kill -2 pid.

Related

How does the "Stop build" button work in Bamboo?

How does the "Stop build" button work in Bamboo? I have a job that calls a Python3 script to run some tests on a machine. Does Bamboo send a Ctrl+C (SIGINT) to the process when "Stop build" is pressed? SIGKILL?
My script uses multiprocessing and has a graceful shutdown when it receives a SIGINT signal, but when I press "Stop build" it seems to kill the main process and let the rest of the processes keep living...
Based on my Bamboo logs it appears that it sends a SIGQUIT signal followed by a SIGTERM signal five seconds later:
17:24:02 Executing kill -3 66265 # this sends SIGQUIT
17:24:07 Killing: 66265
17:24:07 Executing kill 66265 # this sends SIGTERM
By adding a signal handler like so I was able to catch it and gracefully exit my processes:
def signal_handler(self, signum, frame):
print(f"Received a 'kill -{signum}'! Cleaning up...")
self.cleanup()
# put these inside of the main function
signal.signal(signal.SIGQUIT, self.signal_handler)
signal.signal(signal.SIGTERM, self.signal_handler)
According to this post on the Bamboo forums, Bamboo sends SIGTERM to the process but it doesn't mention the SIGQUIT that is sent first.
The above only seems to be true if you enable "Force stop build" in Plan Configuration -> Other. If "Force stop build" is not enabled then "Stop build" does not seem to do anything.

Sending the Valgrind to the background

I'v started a process with valgrind to find the leaks with the option --leak-check=full and redirecting the stdout and stderr outputs to a file. But the program seems to be running too long and now I want to send the process to the background so that I can close the terminal and check on the results at later time.
Here I've found that by using ctrl +z it will suspend the process and with bg and disown commands its possible to remove the process from the terminal and run on the background
But when I try that with valgrind the process doesnot respond to the ctrl + z command
Is there an alternative way to send the valgrind process to background? Or am I doing the whole thing wrong?

failed to kill a returning process

I have an invisible mspaint.exe process (no open window) that runs apparently at startup on WINDOWS XP.
I tried the usual ways to kill it, but none of them worked.
1) Task Manager: the process disappears but returns immediately.
2) Command Prompt: if I do
taskkill -f /im mspaint.exe
I receive the SUCCESS message BUT the process mspaint remains, with the same PID.
If I specify the PID number, then I also get the SUCCESS message but the process mspaint.exe remains with a new PID.
3) Process Explorer: the kill command has no effect.
There is a parent svchost.exe process that I killed but still I could not get rid of child process mspaint.exe
Any advice is welcome.
Try right-clicking on mspaint.exe in the processes tab in task manager and selecting "Kill Process Tree".
It seems like it could be a virus. I suggest downloading Malware Bytes (free) and doing a scan. http://www.malwarebytes.org

How to run a PHP script via SSH and keep it running after I quit

I'm trying to restart a custom IRC bot. I tried various commands :
load.php
daemon load.php
daemon load.php &&
But that makes the script execute inside the console (I see all the output) and when I quit the bot quits as well.
The bot author only taught me the IRC commands so I'm a bit lost.
You can install a package called screen. Then, run screen -dm php load.php and resume with screen -dR
This will allow you to run the script in the background, and still be able to use your current SSH terminal. You can also logout and the process will still be running.
Chances are good the shell is sending the HUP signal to all its running children when you log out to indicate that "the line has been hung up" (a plain old telephone system modem reference to a line being "hung up" when disconnected. You know, because you "hang" the handset on the hook...)
The HUP signal will ask all programs to die conveniently.
Try this:
nohup load.php &
The nohup asks for the next program executed to ignore the HUP signal. See signal(7) and the nohup(1) manpages for details. The & asks the shell to execute the program in the background.
Clay's answer of using screen(1) is pretty awesome, definitely look into screen(1) or tmux(1), but I don't think that they are necessary for this problem.
This line might help you
php load.php &

executing NSTask in the background

I'm executing a shell script using NSTask but the problem is that the shell script is one of those scripts that keeps running until you press control+c. It starts up fine but then my mac application just waits for it to end. How can I make it so that it detaches the task from the mac application and goes and runs it in a background.
Don't call waitUntilExit or otherwise run the task synchronously. If the task has lots of output, make sure you read and process the data or else an i/o buffer will fill and it'll block.
In general, you shouldn't be using NSTask for a daemon like operation anyway. You should be using launchd.