title: Create a program to calculate the maximum number of processes in the system
body: <p>I have the following code, which I'm trying to calculate all process. I do not understand how to calculate the maximum number of process.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main() 
  {
     int pid, pidmax = 0;
     while(1) 
     {
         pid = fork();
         pidmax = getpid();
         if(pid == 0){
             if(pidmax &lt; getpid())
                 pidmax = getpid();
             printf("pid: %d, max: %d\n", getpid(), pidmax);  
             return 0;
         }
  
         if(pid == -1) {
          printf("Maximum process: %d\n", pidmax);
          exit(-1);
         }
      }
      return 0;
  }
  </code></pre>