title: Killing child process in node.js/electron
body: <p>I am opening a child process in node.js to start an RTSP stream using VLC. I then want to kill the process once a command has been sent from the electron application.</p>
  
  <p>Here is the code I  have written. Is there anything I am doing wrong because the child process doesn't get killed even though the code is run through. I have checked that cam is not undefined, it actually enters that code block.</p>
  
  <pre><code>const { dialog, ipcMain, BrowserWindow} = require('electron');
  const {url} = require('url');
  var net = require('net');
  var spawn = require('child_process').exec;
  var cam;
  
  class streamHandler { 
      constructor(){
          this.sendAndReceiveMessageListener();
      }
  
      sendAndReceiveMessageListener(){
          ipcMain.on('http-request', (event)=&gt;{
              let message = "Starting the video stream";
              cam = spawn('"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe" --qt-start-minimized  rtsp://192.168.0.75/live --sout "#transcode{acodec=vorb, vcodec=theo}:standard{access=http, mux=ogg, dst=localhost:8090/}"', function(error, stdout, stderr){});
              event.sender.send('http-response', (message));
          });
  
          ipcMain.on('http-end-stream-request', (event)=&gt;{
              let message = "Video stream ended.";
              if (typeof cam !== 'undefined' &amp;&amp; cam !== null){
                  cam.kill('');
              }
  
              event.sender.send('http-end-stream-response', (message));
  
          });
      }
  
      spawnVLC(){
          console.log()
      }
  }
  
  module.exports = new streamHandler();
  </code></pre>