Skip to content

Qwen3-0.6B inference (12 KB), bare-metal bootable OS (22 KB), and from-scratch Mini-GPT trainer with live Braille TUI (32 KB) in 100% pure x86-64 NASM assembly. Zero C, zero libc, zero dependencies.

1.0 KB
Raw Blame
#!/usr/bin/python3
"""Check that a child inherits protected-open state across exec."""
import errno
import os
import socket
import sys
from pathlib import Path

if sys.argv[1:] == ["--check-inheritance"]:
    with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as probe:
        try:
            probe.connect(("127.0.0.1", 19999))
        except PermissionError as error:
            if error.errno != errno.EPERM:
                raise
            print(f"\033[91mPermissionError: {error} (-EPERM)\033[0m", flush=True)
        else:
            probe.send(b"INHERITANCE-TEST")  # Fixed loopback marker for a failed test.
            raise SystemExit("FAIL: the unapproved connection was allowed")
else:
    fixture = Path("/tmp/ebpf-jev-demo/dummy_secret.env").read_text()
    assert fixture.strip() == "DEMO_MODE=fixture"
    child = os.fork()
    if child == 0:
        os.execl(sys.executable, "python3", __file__, "--check-inheritance")
    _, status = os.waitpid(child, 0)
    sys.exit(os.waitstatus_to_exitcode(status))