code: def xrun(command, options, log=None, _log_container_as_started=False, logfile=None, timeout=-1, kill_callback=None):
      cmd = " ".join([command] + list(map(str, options)) )
      def _print_info(msg):
          if msg is None: return
          if log:
              log.info(msg)
          else:
              print(msg)
      def _print_warn(msg):
          if msg is None: return
          if log:
              log.warn(msg)
          else:
              print(msg)
      _print_info(u"Running: {0:s}".format(cmd))
      sys.stdout.flush()
      starttime = time.time()
      process = p = None
      try:
          foutname = os.path.join("/tmp", "stimela_output_{0:s}_{1:f}".format(hashlib.md5(cmd.encode('utf-8')).hexdigest(), starttime))
          with open(foutname, "w+") as fout:
              p = process = subprocess.Popen(cmd,
                                              stderr=fout,
                                              stdout=fout,
                                              shell=True)
              def clock_killer(p):
                  while process.poll() is None and (timeout >= 0):
                      currenttime = time.time()
                      if (currenttime - starttime < timeout):
                          DEBUG and _print_warn(u"Clock Reaper: has been running for {0:f}, must finish in {1:f}".format(currenttime - starttime, timeout))
                      else:
                          _print_warn(u"Clock Reaper: Timeout reached for '{0:s}'... sending the KILL signal".format(cmd))
                          (kill_callback is not None) and kill_callback()
                      time.sleep(INTERRUPT_TIME)
              Thread(target=clock_killer, args=tuple([p])).start()
              while (process.poll() is None):
                  currenttime = time.time()
                  DEBUG and _print_info(u"God mode on: has been running for {0:f}".format(currenttime - starttime))
                  time.sleep(INTERRUPT_TIME)
              assert hasattr(process, "returncode"), "No returncode after termination!"
          with open(foutname, "r") as fout:
              _print_info(fout.read())
      finally:
          if (process is not None) and process.returncode:
              raise StimelaCabRuntimeError('%s: returns errr code %d' % (command, process.returncode))