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 pass_fds parameter to PtyProcess:spawn() #49

Merged
merged 1 commit into from
Jan 7, 2019

Conversation

eugpermar
Copy link
Contributor

@eugpermar eugpermar commented Dec 27, 2018

Same format as subprocess.Popen

@eugpermar
Copy link
Contributor Author

Hi! Previous travis tests failed because of ubuntu 14.04 dash file descriptor limit. Updated with bash, could you please re-launch travis?

@@ -190,6 +190,10 @@ def spawn(

Dimensions of the psuedoterminal used for the subprocess can be
specified as a tuple (rows, cols), or the default (24, 80) will be used.

By default, all file descriptors except 0, 1 and 2 are closed. This
behavior can be overridden with pass_fds, a list of file descriptors to
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: you document it as a list, but it will only work with a tuple, because you concatenate it to a tuple (pass_fds + (exec_err_pipe_write,)). Let's cast it to a set, like subprocess does; that should work with any sequence, and also eliminates any odd behaviour with duplicate entries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right!

'-c',
'printf hello >&{}'.format(temp_file_fd)],
echo=True,
pass_fds=(temp_file_fd,))
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth having a test that when you don't specify it in pass_fds, the child process can't access it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that the more tests, the better :) I've added that one too.

@eugpermar eugpermar force-pushed the master branch 2 times, most recently from 2a0cddc to 55cf239 Compare January 2, 2019 18:32
@eugpermar
Copy link
Contributor Author

Hi! I think I've addressed both comments, could you take a look?

@takluyver takluyver merged commit 3931cd4 into pexpect:master Jan 7, 2019
@takluyver
Copy link
Member

Thanks

@eugpermar
Copy link
Contributor Author

Thank you! As soon as pexpect tests download this feature from pip, I will continue PR pexpect/pexpect#546 😄

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