title: After suspending child process with SIGTSTP, shell not responding
body: <p>I'm coding a basic shell in C, and I'm working on suspending a child process right now.</p>
  
  <p>I think my signal handler is correct, and my child process is suspending, but after that, the terminal should return to the parent process and that's not happening.</p>
  
  <p>The child is suspended, but my shell isn't registering any input or output anymore. tcsetpgrp() doesn't seem to be helping.</p>
  
  <p>Here's my signal handler in my shell code for SIGTSTP:</p>
  
  <pre><code>void suspend(int sig) {
      pid_t pid;
      sigset_t mask;
      //mpid is the pgid of this shell.
      tcsetpgrp(STDIN_FILENO, mpid);
      tcsetpgrp(STDOUT_FILENO, mpid);
      sigemptyset(&amp;mask);
      sigaddset(&amp;mask, SIGTSTP);
      sigprocmask(SIG_UNBLOCK, &amp;mask, NULL);
      signal(SIGTSTP, SIG_DFL);
      //active.pid is the pid of the child currently in the fg.
      if (active.pid != 0) {
          kill(active.pid, SIGTSTP);
      }
      else{
          //if this code is being run in the child, child calls SIGTSTP on itself.
          pid = getpid();
          if (pid != 0 &amp;&amp; pid != mpid){
              kill(pid, SIGTSTP);
          }
      }
      signal(SIGTSTP, suspend);
  }
  </code></pre>
  
  <p>Can anyone tell me what I'm doing wrong?</p>
  
  <p>Am I suspending my shell along with the child, and do I need to return stdin and stdout to the shell somehow? How would I do this?</p>
  
  <p>Thanks!</p>