I am trying to debug a C++ application which invokes many command line applications such as grep, etc through a the system() system call. I need to see all the commands the application is executing through the system() call.
I tried to view these commands by enabling history and view the .history file. But these commands are not executed through a terminal. The history file has only the commands executed interactively.
Any idea how this can be done?
To trace every command executed by “yourProgram”:
eg:
If you want to correlate these execs to system() calls, you can use that command:
eg:
Finally, if you are using Solaris 10 or newer, you can use Dtrace for this task like this:
which will give that output with the same “a” code:
PS: By the way system() isn’t a system call but a standard library function.