-
Notifications
You must be signed in to change notification settings - Fork 296
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
Only inherit the handles that are really needed. #887
Only inherit the handles that are really needed. #887
Conversation
26e1619
to
da62c51
Compare
da62c51
to
db3c030
Compare
src/vcpkg/base/system.process.cpp
Outdated
// Ensure that only the write handle to STDOUT and the read handle to STDIN are inherited. | ||
// from https://devblogs.microsoft.com/oldnewthing/20111216-00/?p=8873 | ||
SIZE_T size = 0; | ||
if (InitializeProcThreadAttributeList(nullptr, 1, 0, &size) || GetLastError() != ERROR_INSUFFICIENT_BUFFER) |
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.
I would really like to see an RAII type for this.
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.
Only for the clean up or for everything? So should a failure in the constructor (calls InitializeProcThreadAttributeList) throw an exception?
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.
I wish it were for the pipes too but that's preexisting so won't ask you to go there. I meant something like:
struct ProcAttributeList {
static ExpectedL<ProcAttributeList> create(DWORD dwAttributeCount);
ExpectedL<Unit> update_attribute(DWORD_PTR Attribute, PVOID lpValue, SIZE_T cbSize);
~ProcAttributeList();
LPPROC_THREAD_ATTRIBUTE_LIST get() const noexcept { return reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(buffer.data()); }
ProcAttributeList(const ProcAttributeList&) = delete;
ProcAttributeList& operator=(const ProcAttributeList&) = delete;
private:
ProcAttributeList(/* *** */);
std::vector<unsigned char> buffer;
};
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.
Have done this in a3bbb30
Thanks for the fix! |
Currently all handles are inherited to child processes. For more information see https://discord.com/channels/400588936151433218/687365466422902841/1072485165491814430