title: Querying the status of children in Unix shell
body: <p>I'm trying to implement a Unix shell for a class project and I'm running into some issues. Namely this method</p>
  
  <pre><code>void checkStatus()
  {
  printf("checking status\n");
  job_t* checkStart = first_job;
  while(checkStart != NULL)
  {
      process_t* processStart = checkStart-&gt;first_process;
      while(processStart != NULL)
      {
          int status;
          pid_t test = waitpid(processStart-&gt;pid, &amp;status, WUNTRACED | WNOHANG);
          printf("%d\n", processStart-&gt;pid);
          printf("%s\n", strerror(errno));
          printf("%d\n", status);
          printf("%d\n", test);
  
          if(WIFEXITED(status))
          {
              printf("exited\n");
          }
          if(WIFSTOPPED(status))
          {
              printf("stopped\n");
          }
          processStart = processStart-&gt;next;
      }
      checkStart = checkStart-&gt;next;
  }
  }
  </code></pre>
  
  <p>is supposed to query the status of all of the processes that are running or have been run so that the process structs can be updated (I need to be able to print out the status of each one). When I try to test this by running a foreground process and using ctrl+z to pause it, it always returns as exited. Also if I use ctrl+c to stop it it returns an error saying no child processes are available but also returns exited. Am I querying the statuses wrong? Also this is supposed to be implemented without using signals so I can't go that route.</p>
  
  <p>Thanks!</p>