title: SIGSTOP does not work when scripted
body: <p>I have a really huge archive, which must be extracted file by file and further processed. I don't have enough memory to extract the whole archive (neither in RAM nor on the flash) - thus I wrote a small application which stops (<code>raise(SIGSTOP)</code>) after each extracted file. An equivalent could be this code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  
  int main() {
      printf("started.\n"); fflush(stdout);
      sleep(2);                             // extracting archive
      printf("stopping\n"); fflush(stdout);
      raise(SIGSTOP);                       // stopping
      printf("resume + done\n"); fflush(stdout);
      return 0;
  }
  </code></pre>
  
  <p>This works fine while I execute this in the terminal:</p>
  
  <pre><code>$ gcc -o dosleep main.c
  $ ./dosleep 
  started.
  stopping
  
  [1]+  Stopped                 ./dosleep
  $ fg
  ./dosleep
  resume + done
  $ 
  </code></pre>
  
  <p>But when calling the method from a script, the command never returns:</p>
  
  <pre><code>$ cat doit.sh 
  #!/bin/sh
  echo "STARTING"
  ./dosleep
  echo "BACK"
  $ ./doit.sh 
  STARTING
  started.
  stopping
  
  ^C^C^C^C^C^C
  </code></pre>
  
  <p>Why do terminal and script behave so differently? Is there a way to change this behavior?</p>
  
  <p>Thanks, Karl</p>