Merge bitcoin/bitcoin#34385: subprocess: Fix -Wunused-private-field when building with clang-cl on Windows

1b36bf0c5d71ea2e7e3595eb10611ea1a8c3a0d1 subprocess: Fix `-Wunused-private-field` for `Child` class on Windows (Hennadii Stepanov)
9f2b338bc01832e335f652e23f1318ee44cdd63c subprocess: Fix `-Wunused-private-field` for `Popen` class on Windows (Hennadii Stepanov)

Pull request description:

  This PR is a prerequisite for https://github.com/bitcoin/bitcoin/pull/31507.

  It resolves `-Wunused-private-field` warnings triggered in `src/util/subprocess.h` when compiling with clang-cl on Windows:
  ```
  D:\a\bitcoin\bitcoin\src\util/subprocess.h(759,10): warning : private field 'parent_' is not used [-Wunused-private-field] [D:\a\bitcoin\bitcoin\build\src\util\bitcoin_util.vcxproj]
  D:\a\bitcoin\bitcoin\src\util/subprocess.h(760,7): warning : private field 'err_wr_pipe_' is not used [-Wunused-private-field] [D:\a\bitcoin\bitcoin\build\src\util\bitcoin_util.vcxproj]
  D:\a\bitcoin\bitcoin\src\util/subprocess.h(1038,7): warning : private field 'child_pid_' is not used [-Wunused-private-field] [D:\a\bitcoin\bitcoin\build\src\util\bitcoin_util.vcxproj]
  ```

  Only the second commit has been [submitted](https://github.com/arun11299/cpp-subprocess/pull/127) upstream. The first commit is specific to this repository and not applicable upstream.

ACKs for top commit:
  maflcko:
    review ACK 1b36bf0c5d71ea2e7e3595eb10611ea1a8c3a0d1 👋
  purpleKarrot:
    ACK 1b36bf0c5d71ea2e7e3595eb10611ea1a8c3a0d1
  sedited:
    ACK 1b36bf0c5d71ea2e7e3595eb10611ea1a8c3a0d1

Tree-SHA512: 1bc0544d769264fa74d2f39150595ee6339af4bca7b7051ecaecbe234c17b643b715e00cfb9302a16ffc4856957f4fa47c216aebf03fec0cd95c387f51bd29a6
This commit is contained in:
merge-script 2026-02-19 18:05:50 +01:00
commit 097c18239b
No known key found for this signature in database
GPG Key ID: 9B79B45691DB4173

View File

@ -738,6 +738,7 @@ private:
Popen* popen_ = nullptr;
};
#ifndef __USING_WINDOWS__
/*!
* A helper class to Popen.
* This takes care of all the fork-exec logic
@ -759,6 +760,7 @@ private:
Popen* parent_ = nullptr;
int err_wr_pipe_ = -1;
};
#endif
// Fwd Decl.
class Streams;
@ -930,7 +932,9 @@ class Popen
{
public:
friend struct detail::ArgumentDeducer;
#ifndef __USING_WINDOWS__
friend class detail::Child;
#endif
template <typename... Args>
Popen(std::initializer_list<const char*> cmd_args, Args&& ...args)
@ -1009,6 +1013,9 @@ private:
#ifdef __USING_WINDOWS__
HANDLE process_handle_;
std::future<void> cleanup_future_;
#else
// Pid of the child process
int child_pid_ = -1;
#endif
std::string exe_name_;
@ -1017,9 +1024,6 @@ private:
std::vector<std::string> vargs_;
std::vector<char*> cargv_;
// Pid of the child process
int child_pid_ = -1;
int retcode_ = -1;
};
@ -1258,8 +1262,8 @@ namespace detail {
}
inline void Child::execute_child() {
#ifndef __USING_WINDOWS__
inline void Child::execute_child() {
int sys_ret = -1;
auto& stream = parent_->stream_;
@ -1319,8 +1323,8 @@ namespace detail {
// Calling application would not get this
// exit failure
_exit (EXIT_FAILURE);
#endif
}
#endif
inline void Streams::setup_comm_channels()