> In a Linux (2.6.34) based platform I have a process that does the > functionality of process management by spawning other processes, monitoring > them etc. > > For debugging purposes I want to spawn a process using valgrind.. So I fork > and exec with the following parameters to execve > > |execvp("/usr/bin/valgrind", args); > args is an array of character pointers.. > > args[0] = /usr/bin/valgrind > args[1] = --log-file=<file_name> > args[2] = path to the program to be started in valgrind > args[3] = argument to the program > args[4] = '\0'| > > But this doesn't work. I see valgrind running, but log file is not generated > and it doesn't see to do anything. > > I did an strace for an invocation of valgrind from the shell and in the exec > call the parameters are similar to what I am passing programmatically. > > Any ideas what might be wrong ?
As Philippe Waroquiers suggests, add six new options "-d -d -d -v -v -v" to the invocation of valgrind. As I suggest, invoke valgrind under strace from your "supervisor": args[0] = "/usr/bin/strace"; args[1] = "-f"; args[2] = "-o"; args[3] = "strace.out"; args[4] = "-e"; args[5] = "trace=file,close,dup,dup2,pipe"; args[6] = "/usr/bin/valgrind"; args[7] = "<first option to valgrind>"; ... args[K] = "./my_app"; args[1+K] = "<first argument to my_app>"; ... args[N-1] = 0; execvp(args[0], args); And as KISS ("Keep It Simple, Sir") suggests, try running: args[0] = "/bin/date"; args[1] = "+%Y-%m-%d"; args[2] = 0; execvp(args[0], args); -- ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users