title: gdb debugging process after exec call
body: <p>I don't know how to debug after the process after calling <code>execle</code>. I've looked at other websites and some suggested using <code>set fork-follow-mode child</code>, which helped me get into the fork. However, after the fork, I exit into the main function and never get into the program I am exec'ing. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>            } else if (!(pid_T2 = fork())) {
                  char **env = NULL;
                  char *units_env = NULL;
                  char *sleep_env = NULL;
                  size_t sleep_sz = 16;
  
                  env = (char **) malloc(3 * sizeof(char *));
                  sleep_env = (char *) malloc(sleep_sz * sizeof(char));
                  snprintf(sleep_env, sleep_sz, "TSTALL=%d", cmd_args-&gt;sleep_num);
                  if (cmd_args-&gt;kb) {
                          units_env = "UNITS=1";
                  } else {
                          units_env = "UNITS=0";
                  }
                  *(env) = units_env; *(env + 1) = sleep_env; *(env + 2) = "TMOM=0";
  
                  /*printf("%s %s\n", *(env), *(env + 1));*/
  
                  close(pipe_A2toT2[1]);
                  dup2(pipe_A2toT2[0], 0);
                  close(pipe_A2toT2[0]);
  
                  execle("totalsize", "totalsize", NULL, env); //Exits to main after this line, never goes into program.
            }
  </code></pre>
  
  <p>I know that the process image gets replaced by exec call, however why am I still exiting to this program's main instead of going into <code>totalsize</code> program?</p>