title: spawn child process not exiting in node js
body: <p>I am trying to create a child process in node js using following code</p>
  
  <p>fileone.js</p>
  
  <pre><code>    var childProcess = require('child_process');
  
    var workerProcess = childProcess.spawn('node', ['api/filetwo.js', id]);
      workerProcess.stdout.on('data', function (data) {
       console.log('stdout: ' + data);
       //res.jsonp('hi output view in console');
      });
  
      workerProcess.stderr.on('data', function (data) {
         console.log('stderr: ' + data);
         res.jsonp('hi error occured');
      });
  
      workerProcess.on('close', function (code) {
         console.log('child process exited with code ' + code);
         res.jsonp('hi process closed');
      });
  </code></pre>
  
  <p>filetwo.js</p>
  
  <pre><code>console.log("file two called");
  </code></pre>
  
  <p>if I run this piece of code I get message in console and response at client side 'hi process closed.'</p>
  
  <p>I want to query database in child process so</p>
  
  <p>filetwo.js</p>
  
  <pre><code>connection.query(query,function(error,result){
    if(error){
    console.log("error",error)
  }else{
   console.log("result",result);
   console.log("Child Process " + process.argv[2] + " executed." );
  }
  })
  </code></pre>
  
  <p>I can see both console message in terminal but I don't get any response on client side. What am I missing please help.</p>