Sending the Valgrind to the background - valgrind

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?

Related

Can I retrieve the output of a program, that is running in another terminal and/or run by root as e.g a cronjob?

Just for the sake of the question, say I open a terminal an log into my Linux computer. I run a program that keeps outputting information on my screen, looping. I close the terminal window, and the program shuts down.
I set up a cronjob or a startup script that launches the same program as in example 1. The program is looping now, run as root.
I open a terminal, and log into my computer through SSH. Can I make a Bash script that retrieves the output of said program, even if it's running somewhere in the background? I mean, is the program "virtually" outputting information (as in example 1)?
The program closes stdout and stderr when it exits. Looping it as you describe will just cause it to start and exit continuously. You could look at redirecting stdout and stderr.

jython script doesnt start when run in background

I have a Jython script that is meant to run as a daemon in background, but somehow it doesn't start at all when I'm trying to run it in background.
So I've tried to do a most basic "hello world" script, it works fine if I execute it in console like
./mysqript.py
But same script executed like
./mysqript.py &
fails. It doesn't output error messages, it doesn't throw exceptions, it's actually not even quitting silently. It's just hanging forever in the process list as a zombie process doing nothing.
Why is that and how can I make it work?
PS: Environment is Jython2.7 beta.

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.

valgrind on server process

hi i am new to valgrind. I know how to run valgrind on executable files from command line. But how do you run valgrind on server processes like apache/myqld/traffic server etc ..
I want to run valgrind on traffic server (http://incubator.apache.org/projects/trafficserver.html) to detect some memory leaks taking place in the plugin I have written.
Any suggestions ?
thanks,
pigol
You have to start the server under Valgrind's control. Simply take the server's normal start command, and prepend it with valgrind.
Valgrind will attach to every process your main "server" process spawns. When each thread or process ends, Valgrind will output its analysis, so I'd recommend piping that to a file (not sure if it comes out on stderr or stdout.)
If your usual start command is /usr/local/mysql/bin/mysqld, start the server instead with valgrind /usr/local/mysql/bin/mysqld.
If you usually start the service with a script (like /etc/init.d/mysql start) you'll probably need to look inside the script for the actual command the script executes, and run that instead of the script.
Don't forget to pass the --leak-check=full option to valgrind to get the memory leak report.