Skip to content

Reset the child signal mask before exec - #50

Merged
guillerodriguez merged 1 commit into
masterfrom
fix/child-proc-reset-signal-mask
Aug 3, 2026
Merged

Reset the child signal mask before exec#50
guillerodriguez merged 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
@guillerodriguez

Copy link
Copy Markdown
Contributor Author

CI is failing on macOS. It seems to be the "exec should not leak fds" Malva test, so unrelated to this PR. But we should fix that first. Will have a look.

@guillerodriguez

Copy link
Copy Markdown
Contributor Author

Fixed Malva test, CI is green now.

@guillerodriguez
guillerodriguez merged commit 0089a7c into master Aug 3, 2026
5 of 7 checks passed
@guillerodriguez
guillerodriguez deleted the fix/child-proc-reset-signal-mask branch August 3, 2026 06:42
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