title: Kill rosbag gracefully via kill
body: <p>I'd like to kill a <code>rosbag</code> instance gracefully via terminal.
  Gracefully means in that case, that the <code>rosbag</code> file doesn't have the suffix <em>.active</em> after kill.</p>
  
  <p>so I do the following from terminal to send the recommended <code>SIGINT</code> to rosbag:</p>
  
  <pre><code>$ rosbag record /some/topic &amp;
  $ RPID=$!
  $ # do some stuff 
  $ kill -2 $RPID
  </code></pre>
  
  <p>Unfortunately, the bag remains <em>active</em> and it can happen that not everything was stored to the disk.
  However, if I put rosbag into a launch file, it seems to work:</p>
  
  <pre><code>$ roslaunch rosbag_record.launch &amp;
  $ LPID=$!
  $ # do some stuff 
  $ kill -2 $LPID
  </code></pre>
  
  <p>Now the rosbag stays intact and it was stored without the <em>active</em> suffix.</p>
  
  <p>Now the interesting question is, what am I doing wrong in the first case.
  I though that killing a launch file, <strong>and in this case killing the roscore</strong>,  raises a <code>ros::shutdown()</code> which causes a <code>SIGINT</code> in all processes.
  But the manual way by using <code>kill</code> seems to has a different behavior.</p>