Skip to content

Reset the child signal mask before exec - #50

Open
guillerodriguez wants to merge 1 commit into
masterfrom
fix/child-proc-reset-signal-mask
Open

Reset the child signal mask before exec#50
guillerodriguez wants to merge 1 commit into
masterfrom
fix/child-proc-reset-signal-mask

Conversation

@guillerodriguez

Copy link
Copy Markdown
Contributor

When spawning a process via Runtime.exec() or ProcessBuilder, the executed process inherits the signal mask of the JVM thread that spawned it.

The JVM's signal mask is an implementation detail of the runtime, and not part of the execution environment a child program expects. The mask must therefore be cleared when spawning child processes: otherwise, they may exhibit unexpected behaviour depending on which signals are blocked (e.g. cannot be interrupted with SIGINT, will not receive SIGPIPE when writing to a closed pipe, etc.).

Fix by installing an empty signal mask in the child immediately before executing the target program.

Fixes #49 (BZ#126539)

When spawning a process via Runtime.exec() or ProcessBuilder, the
executed process inherits the signal mask of the JVM thread that
spawned it.

The JVM's signal mask is an implementation detail of the runtime,
and not part of the execution environment a child program expects.
The mask must therefore be cleared when spawning child processes:
otherwise, they may exhibit unexpected behaviour depending on which
signals are blocked (e.g. cannot be interrupted with SIGINT, will
not receive SIGPIPE when writing to a closed pipe, etc.).

Fix by installing an empty signal mask in the child immediately
before executing the target program.

Fixes #49 (BZ#126539)

Signed-off-by: Guillermo Rodríguez <grodriguez@ingelabs.com>
@guillerodriguez
guillerodriguez requested a review from phvega July 31, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Child processes should start with an empty signal mask

2 participants