title: send signal between scripts (bash)
body: <p>I've a little problem, probably it's a stupid question, but I started learning bash about a week ago... 
  I have 2 script, a.sh and b.sh. I need to make both running constantly. b.sh should waits for a signal from a.sh </p>
  
  <p>(I'm trying to explain: 
  a.sh and b.sh run --> a.sh sends a signal to b.sh -> b.sh traps signal, does something --> a.sh does something else and then sends another signal --> b.sh traps signal, does something --> etc.)</p>
  
  <p>This is what I've tried:</p>
  
  <p>a.sh:</p>
  
  <pre><code>#!/bin/bash
  ./b.sh &amp;;
  bpid=$!;
  # do something.....
  while true
  do
       #do something....
       if [ condition ]
       then
            kill -SIGUSR1 $bpid;
       fi
  done
  </code></pre>
  
  <p>b.sh:</p>
  
  <pre><code>#!/bin/bash 
  while true
  do
       trap "echo I'm here;" SIGUSR1;
  done
  </code></pre>
  
  <p>When I run a.sh I get no output from b.sh, even if I redirect the standard output to a file...
  However, when I run b.sh in background from my bash shell, it seems to answer to my SIGUSR1 (sent with the same command, directly from shell) (I'm getting the right output)
  What I'm missing?</p>
  
  <p>EDIT:
  this is a simple example that I'm trying to run:</p>
  
  <p>a.sh:</p>
  
  <pre><code>#!/bin/bash
  ./b.sh &amp;
  lastpid=$!;
  if [ "$1" == "something" ]
  then    
      kill -SIGUSR1 $lastpid;
  fi
  </code></pre>
  
  <p>b.sh:</p>
  
  <pre><code>#!/bin/bash
  trap "echo testlog 1&gt;temp" SIGUSR1;
  while true
  do
      wait
  done
  </code></pre>
  
  <p>I can't get the file "temp" when running a.sh. 
  However if I execute <code>./b.sh &amp;</code> and then <code>kill -SIGUSR1 PIDOFB</code> manually, everything working fine...</p>