docs: function (cfg, state, n) {
          // Node 0.8 and 0.10 differently handle spawning errors ('exit' vs 'error'), but errors that happened after
          // launching the command are both handled in 'exit' callback
          return function (code, signal) {
              // See http://tldp.org/LDP/abs/html/exitcodes.html and http://stackoverflow.com/a/1535733/
              if (code === 0 || signal == "SIGTERM" || state.resetCalled) {
                  return;
              }
  
              var isNotRecoverable = (code == 127 || code == 126);
              if (isNotRecoverable) {
                  ++state.erroredPhantomInstances;
                  var path = cfg.phantomPath;
                  if (code == 127) {
                      logger.logError("Spawn: exited with code 127. PhantomJS executable not found. Make sure to download PhantomJS and add its folder to your system's PATH, or pass the full path directly to Attester via --phantomjs-path.\nUsed command: '" + path + "'");
                  } else if (code == 126) {
                      logger.logError("Spawn: exited with code 126. Unable to execute PhantomJS. Make sure to have proper read & execute permissions set.\nUsed command: '" + path + "'");
                  }
                  checkIfAllPhantomsDied(cfg, state);
                  return;
              }
  
              // Now, try to recover unless retried too many times
  
              // prepare error message
              var errMsg;
              if (code == 75) {
                  errMsg = "Spawn: PhantomJS[" + n + "] exited with code 75: unable to load attester page within specified timeout, or errors happened while loading.";
                  if (cfg.phantomInstances > 1) {
                      errMsg += " You may try decreasing the number of PhantomJS instances in attester config to avoid that problem.";
                  }
              } else {
                  errMsg = "Spawn: PhantomJS[" + n + "] exited with code " + code + " and signal " + signal;
              }
  
              // check how many retries happened for this instance
              var retries = state.retries;
              retries[n] = (retries[n] || 0) + 1;
              if (retries[n] < cfg.maxRetries) {
                  // log just a warning and try rebooting
                  logger.logWarn(errMsg);
                  logger.logWarn("Trying to reboot instance nr " + n + "...");
                  this.bootPhantom(cfg, state, n);
              } else {
                  logger.logError(errMsg);
                  ++state.erroredPhantomInstances;
                  checkIfAllPhantomsDied(cfg, state);
              }
          };
      }