title: Creating my own shell. Handling Ctrl-Z and then sending SIGCONT closes the process instead of continue it
body: <p>I am creating my own shell in C language. So far I implemented many features but the thing I am having problems with is CTRL-Z handling(SIGTSTP). Let me specify the problem over successful attempts:</p>
  
  <ul>
  <li><p>When I execute a program in my shell (like gedit), and then press Ctrl-Z it executes kill(p_id, SIGTSTP) and stops that process. The shell also adds the process id in background_processes array so we can reach it in further. Then if I type "fg" in my shell, it brings the process to the foreground and executes kill(p_id, SIGCONT) so we can continue to use the program. Also the shell waits for the process to complete by executing waitpid function. We close the program by clicking X button or pressing Ctrl-C. Exact same thing in Linux shell. SUCCESFULL!!!</p></li>
  <li><p>If I execute a program in my shell (like gedit) in background by specifying &amp; (ampersand), it automatically starts this process in backgrounds by not waiting the process. But it adds the process id in background_processes array so we can reach it in further. Then when I type "fg" in my shell, it brings the process to the foreground. It actually waits for the process to complete by executing waitpid function. Also it doesn't matter if have more than one process in background, they will be bring to the foreground one by one. We close the programs by clicking X button or pressing Ctrl-C. Exact same thing in Linux shell. SUCCESFULL!!!</p></li>
  <li><p>Lets execute a process in the foreground and then send it to the background by Ctrl-Z, and execute a process in background. We have 2 processes in the background. If I type "fg" it brings the first background process to the foreground and waits it. If I press X button (close button) which closes the program the shell brings the second process to the foreground and waits for it. Going very well right, thats what we want. So this scenario also worked very well.</p></li>
  <li><p>The problem scenario is the same as the previous scenario in creating processes. When I type "fg" it brings the first background process to the foreground and waits it. But then if I press Ctrl-C it closes both processes!!!!!! It should only closed the first process and should have wait for the second process!!!</p></li>
  </ul>
  
  <p>I searched everywhere, tried everything but couldn't figure it out. But the problem seems like with line 525. When I send SIGCONT signal it closes the process. But if comment that line it doesn't close but also I can't use the process since it is stopped!!!</p>
  
  <p>I have the code in my GitHub repo here : <a href="https://github.com/EmreKumas/Myshell" rel="nofollow noreferrer">https://github.com/EmreKumas/Myshell</a></p>
  
  <p>Thanks for reading...</p>