Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add std{in,out} for communication with child process #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

manuels
Copy link

@manuels manuels commented Oct 2, 2016

No description provided.

assert_eq!(libc::close(io1_fds[0]), 0);

assert_eq!(dup2(io2_fds[1], STDOUT_FILENO), STDOUT_FILENO);
assert_eq!(libc::close(io2_fds[1]), 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: indent these to match the other statements in this block.

Copy link
Contributor

@pcwalton pcwalton left a comment

Choose a reason for hiding this comment

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

I think I would prefer having stdin/stdout access be something you have to explicitly request via a sandbox profile. Servo doesn't need this and I don't want more HANDLEs available in the child process than absolutely necessary.

cmd.stdout.read_exact(&mut buf[..]).unwrap();
assert_eq!(buf, b"B");

cmd.wait().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: fix indentation here too.

assert_eq!(buf, b"A");

io::stdout().write_all(b"B").unwrap();
io::stdout().flush().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: fix indentation here.


// Set this `prctl` flag so that we can wait on our grandchild. (Otherwise it'll be
// reparented to init.)
assert!(seccomp::prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0) == 0);
assert_eq!(seccomp::prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0), 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this cleanup to a separate commit?

@manuels
Copy link
Author

manuels commented Oct 6, 2016

@pcwalton, sure, I should I put this stuff into a new Operation?

@bors-servo
Copy link

☔ The latest upstream changes (presumably #51) made this pull request unmergeable. Please resolve the merge conflicts.

@kdy1
Copy link

kdy1 commented Jan 14, 2020

Sorry for asking a question here.

How can I add stderr support? I need a sandbox, but I'm not familiar with linux programming.

Nevermind. I somehow did it.

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.

None yet

4 participants