On 05/02/2015 06:51 PM, Alex Norman wrote:
I swear I saw a document once about it but now I
cannot find it, I'm wondering
how I can launch my NSM client app, via NSM, but also via a terminal so I can
see the standard out/error? Also, being able to use GDB would be great.
I have a bug somewhere in my app shutdown process [via NSM] that only seems to
happen with NSM. I'd like to resolve that :)
Thanks to anyone who can clue me in or point me to this doc!
Alex
you can debug a running process with gdb
by using gdb -p <pid>
you can at the beginning of your program do something like:
close(1);
close(2);
dup2(some_fd, 1);
dup2(some_fd, 2);
so as to redirect stdout/stderr to where you want.
"some_fd" could even be something like /dev/pts/XX
that you get from a running xterm or whatever and you get
output in that xterm. "ps aux" gives you the column TTY
you can also put some sleep code or whatever so that
you have time to find the PID of your program and attach
gdb to it before anything happens