title: How to execute an a.out file by using exec function family in Linux
body: <p>The aim of this c++ program is about the understanding the cocurrent process mechanism in operating system. And the following code is for the child functions of one process. And the child process have theirs numbers, NO.5 and NO.6.</p>
  
  <p>I'm trying to exectute an a.out file in the NO.6 process. I'm trying to do it this way.</p>
  
  <pre><code>void ChildFunction_For_ProcessNO.4(int i){
      switch(i){
          case(5):
              cout &lt;&lt; "This is process five, and the ID for this process is " &lt;&lt; getpid() &lt;&lt; '\n'
                   &lt;&lt; "and the ID for the parent process is " &lt;&lt; getppid() &lt;&lt; '\n';
              CreateThreads_Five();
              cout &lt;&lt; "Process five has ended.\n" &lt;&lt; '\n';
              break;
          case(6):
              cout &lt;&lt; "This is process six, and the ID for this process is " &lt;&lt; getpid() &lt;&lt; '\n'
                   &lt;&lt; "and the ID for the parent process is " &lt;&lt; getppid() &lt;&lt; '\n';
              execl("./a.out", "a.out", NULL);
              //and I also tried this way
              execl("Home/CLionProjects/Project_1/a.out", "a.out", NULL);
              char buf[100]; 
              cout &lt;&lt; "getcwd: " &lt;&lt; getcwd(buf, sizeof(buf))) &lt;&lt; endl;
              cout &lt;&lt; "Process six has ended.\n";
              break;
      }
  </code></pre>
  
  <p>and the getcwd's output goes like this</p>
  
  <pre><code>getcwd: /home/chengxuyuan/CLionProjects/Project_1/cmake-build-debug
  </code></pre>
  
  <p>The a.out file has already been put in the folder together with the c++ program.
  <a href="https://i.stack.imgur.com/p2POZ.png" rel="nofollow noreferrer">the screenshot of the working directory</a>
  and the compile went well, but there is just no output which ought to be <code>Hello world</code> from the a.out file. How can I solve this problem. Thanks a lot!</p>