run

in lib/cc/analyzer/container.rb [51:97]


      def run(options = [])
        started = Time.now

        command = docker_run_command(options)
        Analyzer.logger.debug("docker run: #{command.inspect}")
        pid, _, out, err = POSIX::Spawn.popen4(*command)

        @t_out = read_stdout(out)
        @t_err = read_stderr(err)
        t_timeout = timeout_thread

        
        
        
        
        
        @t_wait = Thread.new { _, @status = Process.waitpid2(pid) }
        @t_wait.join

        
        
        
        
        [@t_out, @t_err].each(&:join)

        duration =
          if @timed_out
            timeout * 1000
          else
            ((Time.now - started) * 1000).round
          end

        Result.new(
          container_name: @name,
          duration: duration,
          exit_status: @status&.exitstatus,
          maximum_output_exceeded: @maximum_output_exceeded,
          output_byte_count: output_byte_count,
          stderr: @stderr_io.string,
          stdout: @stdout_io.string,
          timed_out: @timed_out,
        )
      ensure
        kill_reader_threads
        t_timeout&.kill
      end