class_docstr: A suite of unit tests for ship_logs.py
  
  Yeah, it's a hack that these tests live in e2e tests.  But since they test python code it's
  just easier this way.
code: def test_signals_are_forwarded(self) -> None:
      cmd = mkcmd(
          """
              import signal
              import time
  
              def handle_sigint(*arg):
                  print("caught sigint!")
  
              signal.signal(signal.SIGINT, handle_sigint)
  
              print("ready!", flush=True)
  
              time.sleep(5)
              """
      )
      with ShipLogServer() as srv:
          # Start a subprocess so we can signal it.
          env = {
              "DET_MASTER": srv.master_url(),
              "DET_SESSION_TOKEN": "token",
              "DET_TASK_LOGGING_METADATA": "{}",
              "DET_SHIPPER_EMIT_STDOUT_LOGS": "1",
          }
          fullcmd = [sys.executable, "-u", ship_logs.__file__] + cmd
          p = subprocess.Popen(fullcmd, env=env, stdout=subprocess.PIPE)
          assert p.stdout
          try:
              # Wait for the granchild log to indicate signals are set up.
              for line in p.stdout:
                  if b"ready!" in line:
                      break
              # Send a signal that is caught and logged, to test signal forwarding.
              p.send_signal(signal.SIGINT)
              for line in p.stdout:
                  if b"caught sigint!" in line:
                      break
              # Send a signal that is not caught, to test for signal exit codes.
              p.send_signal(signal.SIGTERM)
              exit_code = p.wait()
          finally:
              p.kill()
              p.wait()
      assert exit_code == 128 + signal.SIGTERM, exit_code
      assert "".join(srv.logs) == "ready!\ncaught sigint!\n", srv.logs
  
imports: import io
  import json
  import logging
  import os
  import shutil
  import signal
  import socket
  import ssl
  import subprocess
  import sys
  import tempfile
  import textwrap
  import threading
  import time
  from typing import Any, List, Optional
  import pytest
label_desc: Use image node_id 6 for calling the TestShipLogs obj's underlying member method code with example usage: obj.test_signals_are_forwarded() without return types