title: Grabbing the return value from execv()
body: <pre><code>//code for foo (run executable as ./a.out)
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/wait.h&gt;
  
  int main (int argc, char **argv) {
  pid_t pid;
  pid = fork();
  int i = 1;
  char *parms[] = {"test2", "5", NULL}; //test executable named test2   
  if(pid &lt; 0) {
          fprintf(stderr, "Fork failed");
          return 1;
  }
  else if(pid == 0) {
          printf("Child pid is %d\n", pid);
          i = execv("test2", parms);  //exec call to test with a param of 5
  }
  else {
          wait(NULL);
  }
  printf("I is now %d\n", i); //i is still 1 here, why?
  return 0;
  }
  </code></pre>
  
  <p>Hey everybody, I am trying to learn a little bit about fork and execv() calls. I make my foo.c program above make a call to a file I have named test.c. I fork a child and have the child make a call to execv, which will just add 10 to the parameter read in. I am unsure of why the variable does not change, at the bottom of my foo.c function. Does the call need to be a pointer or return an address? Any help would be greatly appreciated. Thanks</p>
  
  <p>Code for test.c (executable named test2)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char ** argv[]) {
          int i = atoi(argv[1]);
          i = i +10;
          printf("I in test is %d\n", i);
          return i;
  }
  </code></pre>