On Thu, Oct 11, 2012 at 10:33 PM, David Daney <ddaney.cavm@xxxxxxxxx> wrote: > On 10/10/2012 11:30 PM, Ajeet Yadav wrote: >> >> Dear All, >> I wish to check the the LD_DEBUG=reloc for both parent and child process. >> >> Code of parent process p1, that is forking the child process p2 >> [ajeet_y@localhost ajeet]$ cat main1.c >> #include <stdio.h> >> #include <unistd.h> >> int main() >> { >> pid_t pid; >> printf("In P1\n"); >> pid = fork(); >> if (pid){ >> sleep(1); >> } else { >> execve("./p2",NULL,NULL); > > > Here you completely replace the Environment of the process execing p2. > >> } >> } > > [...] > > >> >> >> Can anyone help me why I am not getting the relocation information of >> process P2, > > > You are not getting the LD_DEBUG=reloc information because that environment > variable is not set in P2 due to your elimination of the entire environment. > > >> and how to get it ? > > > Pass LD_DEBUG=reloc in the environment of any process for which you wish to > see the dumps. > Thanks, I did the same with system("p2") in this case I get the LD_DEBUG=reloc information for both, knowing that system() works, I checked its fork:exec implementation. As you suggested, I did execve("./p2", NULL, __environ), in this case also I did not get p2 information, finally I did char *argv={"./p2",NULL}; execve("./p2", argv, __environ); now this works perfect. 3 arg is mandatory, but I did not understand, Why I need to pass 2nd arg ?