Skip to content

Double fork - #137

Open
bjorn3 wants to merge 2 commits into
refactor_spawn_servicefrom
double_fork
Open

Double fork#137
bjorn3 wants to merge 2 commits into
refactor_spawn_servicefrom
double_fork

Conversation

@bjorn3

@bjorn3 bjorn3 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

This ensures the service can't accidentally get a controlling tty when opening a file that happened to be a tty. It is also required in a future commit for sending the process group of the service to the background when detaching from the pty.

Also mark ourself as child subreaper to make testing outside of containers a bit easier.

Required for #117

bjorn3 added 2 commits August 11, 2026 12:13
This ensures the service can't accidentally get a controlling tty when
opening a file. It is also required in a future commit for sending the
process group of the service to the background when detaching from the
pty.
Comment thread beam-init/src/services.rs
Err(err) if err.kind() == io::ErrorKind::UnexpectedEof => Ok(child_pid),
Err(err) if err.kind() == io::ErrorKind::UnexpectedEof => {
let mut child_pid = [0; size_of::<pid_t>()];
pid_rx.read_exact(&mut child_pid)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for this to hang with a pid_tx still around? I think this could only happen if we see a failure in a fork and pid_tx is never used there but I'm not sure.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pid_tx would be closed by the exec or exit, so this could only hang if the forked child hangs without ever doing an exec or exiting.

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.

2 participants