code: function runChildAndCaptureOutput(forkedProcess) {
      var stdout_parts = [], stdoutLength = 0, stderr_parts = [], stderrLength = 0,
          deferred = Q.defer();
      forkedProcess.stdout.on('data', function (data) {
          stdout_parts.push(data);
          stdoutLength += data.length;
      });
      forkedProcess.stderr.on('data', function (data) {
          stderr_parts.push(data);
          stderrLength += data.length;
      });
      forkedProcess.on('close', function (code) {
          var child_stdout = convertToString(stdout_parts, stdoutLength),
              child_stderr = convertToString(stderr_parts, stderrLength);
          var resultVal = {
              exitCode: code,
              stdout: child_stdout,
              stderr: child_stderr,
              toString: function () {
                  return child_stderr;
              }
          };
          if (code !== 0) {
              deferred.reject(resultVal);
          } else {
              deferred.resolve(resultVal);
          }
      });
      return deferred.promise;
  
  }
docs: Runs a process created via the node child_process API and captures its output.
  
  @param forkedProcess the process
  @returns {promise|Q.promise} A promise that, when process execution completes normally, is
  resolved with an object with the following properties:
  'stdout': the stdout output of the process
  'stderr': the stderr output of the process
  
  If process completes abnormally (with non-zero exit code), the promise is rejected
  with a value similar to above, except that 'exitCode' holds the exit code.