title: Implementing bash in c , each line holds { >, <, >> , & , | }
body: <p>I'm implementing a simple shell for the <code>bash</code> command in <code>c</code>   .</p>
  
  <p>I've already parsed the line that I want to work with (I stored the input from <code>stdin</code> 
  into a <code>char**</code> array) . Now I'm left with taking care of the following cases : </p>
  
  <pre><code>{ &gt;, &lt;, &gt;&gt; , &amp; , | } 
  </code></pre>
  
  <p>little than ,bigger than , redirection , running a command in the background and pipes.</p>
  
  <p>I'm trying to understand something , if I want to do this :</p>
  
  <pre><code>someApplication &gt; file 
  </code></pre>
  
  <p>or </p>
  
  <pre><code>someApplication &lt; file 
  </code></pre>
  
  <p>or </p>
  
  <pre><code>someApplication &gt;&gt; file 
  </code></pre>
  
  <p>Would <code>forking</code> do any good ,for implementing these cases ? ( meaning ,the use of <code>father</code> &amp; <code>son</code> processes )</p>
  
  <p>The way I see it , only if I have a pipe , like ‫‪<code>ls|grep great‬‬</code>  , then <code>fork</code> would be much more productive since one process would present the files in the directory , and the other one would use the input from the son for completing the right side of the pipe.</p>
  
  <p>Thanks .</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <pre><code>void handleLessThan(char** arguments , int * argumentsCount)
  {
      int fd_fork = fork();
      int fd_sourceFile;
      char sourceFile[30];
  
      if (fd_fork == 0)  // son is running now
      {
          strcpy(arguments[*argumentsCount],sourceFile);
          fd_sourceFile= open(sourceFile, O_RDONLY);
          dup2(fd_sourceFile, 0); .
          execvp(arguments[0],arguments[1]);
      }
  
      else
      {
          // parent
              ?? 
  
  
      }
  
  
  }
  </code></pre>