-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fds accessor #2
base: master
Are you sure you want to change the base?
Fds accessor #2
Conversation
Submitting it here is fine - makes it easier for me to fetch the change and merge it locally. I haven't looked at the patch but it sounds sane, I'll take a proper look ASAP. Thanks. |
test_pstreams.cc
Outdated
explicit pguard(ipstream& in, int signal=SIGKILL) | ||
: buf_(*in.rdbuf()), signal_(signal) { } | ||
explicit pguard(ipstream& is, int signal=SIGKILL) | ||
: buf_(*is.rdbuf()), signal_(signal) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh, this is a stupid warning from Clang. The code is fine. I'll merge this though, just to shut the warning up.
Over the weekend I realized that the better way to handle our problem would be to open all the pipes with That however would be a more drastic change for a portable header-only library-- it would probably require using autoconf or nasty #ifdefs or something. Our case is adequately handled by adding a little locking and setting |
I know I've considered this problem in the past (many years ago), but I don't remember if I came to any conclusion. One option would be additional flags passed to the constructors and (My long-term plan has always been to separate the creation of the child process and pipes into a separate process-management class, which would explicitly support such things, and then build the streambuf functionality around that ... but it's currently vapourware). |
ping I haven't seen anything for a while... |
ping again... Would it be better to submit this on SF? |
This is useful for applying FD_CLOEXEC.
rebased and cleaned up. |
Hi - no, I actually prefer using GH to SF, so this is fine, I'm just really bad at getting through my TODO list. I'll re-review this tomorrow. Thanks for the ping. |
Why does the new function return a Other than that, it looks fine. |
I don't know why it's |
We're using pstreams in a threaded program and running into problems that can be solved with
FD_CLOEXEC
. We can get at theFILE*
s withfopen()
and then the file descriptors withfileno(FILE*)
. But this invokes unnecessary action, and our platform doesn't have anfdclose()
call to clean up.So I wrote a
fds()
accessor that returns the existing file descriptors, rather than new stdio files. This arguably is a better way to provide access to the underlying pipes, because it is easy to callfdopen()
on these file descriptors.Would you consider this? I left the code outside
REDI_EVISCERATE_PSTREAMS
because the interaction with raw I/O is simpler, and setsockopt/ioctl are valid, non-hacky reasons to access the file descriptors, but that is really your call. There's a couple of other small fixes as well. Tested on Ubuntu 17.04, OS X/Xcode 10.13, FreeBSD 11.1.I've submitted this here because I don't have an SF account handy and GH is superior for submitting multiple commits, but I can submit on SF if that's better for you.