-
Notifications
You must be signed in to change notification settings - Fork 37.7k
util: remove unused cpp-subprocess options #29865
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
util: remove unused cpp-subprocess options #29865
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Nice, Concept ACK. |
Concept ACK. |
Are all remaining options used? |
Concept ACK, but could it be that we could need some of these? |
From the 12 available cpp-subprocess options we currently only use 4 (namely bitcoin/src/common/run_command.cpp Line 29 in 22c8614
I.e. the other 8 are unused. This PR currently removes 3 of the 8 unused ones -- the remaining 5 ( cwd , bufsize , environment , close_fds , session_leader ) seemed to be common enough to be useful at some point in the future, but my choice is more based on gut feeling than anything else, as I don't know what future use-cases could be. Concrete suggestions are very welcome. For example, setting environment variables seems like it could be useful, but the code is quite complex for Windows.
Good question. Note that |
Agree that that seems useful. I vaguely remember we even had a use-case for that once, but don't remember it clearly, we did give it up because it was too hard to do in windows.
Oh, whoops, sorry, didn't notice that. FWIW I think it's a valid choice to remove what we're not using and re-introduce it when we do, the code is out there there's little point in keeping unused code in the repository. |
I agree. |
We don't use this option and it's not supported on Windows anyways, so we can get as well rid of it.
We don't seem to ever need this, so remove it.
For our use-case, there doesn't seem to be any need for this.
a5368c1
to
0f84733
Compare
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.
Approach ACK 0f84733.
I have reviewed all commits except the last one (it's still in progress).
The CI run of the combined branch [ this PR + #29868 ] is available here: https://github.com/hebasto/bitcoin/actions/runs/8740663547/job/23984855961
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.
ACK 0f84733.
I'm happy to re-ACK if the #29865 (comment) will be addressed.
This seems likely to have a high maintenance cost. What's the benefit? |
0f84733
to
899be1a
Compare
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.
re-ACK 899be1a.
Force-pushed with the last commit changed to tackle #29865 (comment). Diff to the previous versiondiff --git a/src/util/subprocess.hpp b/src/util/subprocess.hpp
index c7f9a685d1..a85c0b0bff 100644
--- a/src/util/subprocess.hpp
+++ b/src/util/subprocess.hpp
@@ -1210,8 +1210,6 @@ inline void Popen::kill(int sig_num)
inline void Popen::execute_process() noexcept(false)
{
#ifdef __USING_WINDOWS__
- void* environment_string_table_ptr = nullptr;
-
if (exe_name_.length()) {
this->vargs_.insert(this->vargs_.begin(), this->exe_name_);
this->populate_c_argv();
@@ -1258,7 +1256,7 @@ inline void Popen::execute_process() noexcept(false)
NULL, // primary thread security attributes
TRUE, // handles are inherited
creation_flags, // creation flags
- environment_string_table_ptr, // use provided environment
+ NULL, // use environment of the calling process
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFOW pointer
&piProcInfo); // receives PROCESS_INFORMATION
Do you ask what's the benefit of using cpp-subprocess in general (instead of boost::process) or the benefit of removing code that we don't use? If it's the latter and you're worried that this makes backporting upstream fixes harder, I'd argue that there is hardly any activity upstream, the most recent fixes have been done by @hebasto. |
899be1a
to
13adbf7
Compare
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.
re-ACK 13adbf7.
As discussed in #28981 and during the IRC meeting, we are going to treat the new code as our own:
|
ACK 13adbf7 |
#29910 is the next one :) |
The newly introduced cpp-subprocess library provides a good number of options for the
Popen
class:bitcoin/src/util/subprocess.hpp
Lines 1009 to 1020 in 0de63b8
Some of them are either not fully implemented (
shell
, missing an implementation on Windows), implemented in an ugly way (e.g. using "Impoverished, meager, needy, truly needy version of type erasure" forpreexec_func
according to the author's own words) or simply unlikely to be ever needed for our external signer use-case (defer_spawn
). Instead of maintaining incomplete and/or unneeded code, I'd suggest to get rid of it and only keep support for options if there is a strong reason for it.