title: steps to terminate a shell
body: <p>I've read the chapter about the job control in the <code>glibc</code> manual, but I'm wondering what to do with the remaining jobs when the shell is terminated.</p>
  
  <p>I suppose the following steps (following the convention of posix to handle orphaned process groups the first two steps seems obvious):</p>
  
  <ul>
  <li>send an HUP signal to the jobs with the shell's sid</li>
  <li>send a CONTINUE signal to the stopped jobs  with the shell's sid </li>
  <li>free up the resource allocated for the job's data structures </li>
  </ul>
  
  <p>My problem is what if the jobs survive?</p>
  
  <p>I thought that a chance would be changing their session id to free up the sid  and disassociate the process group from the terminal (not sure if that makes sense)</p>
  
  <p>Should I do <code>ioctl(STDIN_FILENO, TIOCSCTTY)</code> to make the session processes lose the controlling terminal and send the signals?</p>
  
  <p>What to do with the <code>tty</code>? Should I launch a login and set it as a new controlling terminal process group of the tty?  </p>
  
  <p>I'm still confused and a clue would be appreciated.</p>