Skip to content

SIGTERM when calling from from pid 1 #4198

Closed

Description

@bddap

What version of Codex is running?

0.41.0

Which model were you using?

not applicable

What platform is your computer?

any linux container runtime

What steps can reproduce the bug?

Container runtimes use a separate pid space. The root command of the container can see its own pid as 1.

docker run --rm alpine sh -c 'echo $$'
> 1

Since it's expected that codex sometimes be run in a container, its reasonable to assume it sometimes may have pid 1. Let's try it out:

FROM ghcr.io/linuxcontainers/alpine

RUN apk add --no-cache curl tar

RUN curl -fL https://github.com/openai/codex/releases/download/rust-v0.41.0/codex-x86_64-unknown-linux-musl.tar.gz \
	| tar -xz codex-x86_64-unknown-linux-musl \
	&& install codex-x86_64-unknown-linux-musl /usr/local/bin/codex \
	&& rm codex-x86_64-unknown-linux-musl
docker run --rm $(docker build -q .) codex debug landlock true; echo $?
> 143

Uh-oh! 143 is SIGTERM!

Here is the culprit btw:

libc::raise(libc::SIGTERM);

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

A likely solution is to check the actual parent id before registering the pre_exec callback, then compare the return value of libc::getppid() to the expected parent id.

Activity

  1. added
    bug
    on Sep 24, 2025
  2. added a commit that references this issue on Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions