-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Enable PID file creation on WIN #15456
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
Conversation
|
|
|
Force pushed in order to add co-author. |
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.
utACK c4372b8b18d2fab2101d904289b78f87703bb6b9
You might have to include process.h?
|
Appveyor build is failing with: |
|
Update: AppVeyor build should now pass. I have updated the description with details |
src/init.cpp
Outdated
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.
nit: Use fsbridge::get_filesystem_error_message(e) instead of e.what()
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.
Ok, can be added. Just note this was not added/modified by me and was merged in #15278 a few days ago
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.
That was OK to use e.what() in other OS except Windows. So you have to use fsbridge::get_filesystem_error_message(e) instead.
|
Concept ACK Excellent first-time contribution! Thanks! Hope to see more PR:s from you! :-) |
|
Concept ACK. |
|
utACK after squash, I think this is better as one commit to have an atomic change |
- Add available WIN PID function - Consider WIN32 in each relevant case - Add new preprocessor definitions to suppress warning - Update error message for generic OS Co-authored-by: Jörn Röder <[email protected]>
|
Yep agree, done. |
|
thanks! |
3f5ad62 Enable PID file creation on Windows - Add available WIN PID function - Consider WIN32 in each relevant case - Add new preprocessor definitions to suppress warning - Update error message for generic OS (riordant) Pull request description: # Introduction As discussed with @laanwj on IRC: - PID file creation was never enabled for Windows, as the `pid_t` filetype is not available for it. However, the WIN32 API contains the header [`Processthreadsapi.h`](https://github.com/CodeShark/x86_64-w64-mingw32/blob/master/include/processthreadsapi.h) which in turn contains the function [`GetCurrentProcessId()`](https://docs.microsoft.com/en-gb/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getcurrentprocessid). ~~This function is called at a higher level by [`_getpid()`](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getpid?view=vs-2017)~~ EDIT: `_getpid()` is not available to the MSVC compiler used in the AppVeyor build. As a result, I have changed the function call to`GetCurrentProcessId()`, which performs the same function and is available to both MinGW & MSVC. This allows one to capture the PID in Windows, without any additional includes - the above function is already available. - Within this PR, I have added a separate line that calls `GetCurrentProcessId()` in the case of a WIN compilation, and the usual `getpid()` otherwise. All code blocks processing PID file logic that avoid WIN32 have been changed to consider it. I have also updated the preprocessor definitions in `libbitcoin_server.vcxproj.in` to suppress a warning related to `std::strerror` for the MSVC build, that was causing the AppVeyor build to fail (see @fanquake comment below). # Rationale - Consistency between OS's running Bitcoin - Applications which build off of `bitcoind`, such as novel front-end clients, often need access to the PID in order to control the daemon. Instead of designing some alternate way of doing this for one system, it should be consistent between all of them. In collaboration with @joernroeder Tree-SHA512: 22fcbf866e99115d12ed29716e68d200d4c118ae2f7b188b7705dc0cf5f0cd0ce5fb18f772744c6238eecd9e6d0922c615e2f0e12a7fe7c810062a79d97aa6a2
Summary: Enable PID file creation on Windows - Add available WIN PID function - Consider WIN32 in each relevant case - Add new preprocessor definitions to suppress warning - Update error message for generic OS Co-authored-by: Jörn Röder <[email protected]> This is a backport of Core [[bitcoin/bitcoin#15456 | PR15456]] Depends on D5775 Test Plan: make check Run the win64 build and run bitcon-qt Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D5776
Summary: Enable PID file creation on Windows - Add available WIN PID function - Consider WIN32 in each relevant case - Add new preprocessor definitions to suppress warning - Update error message for generic OS Co-authored-by: Jörn Röder <[email protected]> This is a backport of Core [[bitcoin/bitcoin#15456 | PR15456]] Depends on D5775 Test Plan: make check Run the win64 build and run bitcon-qt Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D5776
3f5ad62 Enable PID file creation on Windows - Add available WIN PID function - Consider WIN32 in each relevant case - Add new preprocessor definitions to suppress warning - Update error message for generic OS (riordant) Pull request description: # Introduction As discussed with @laanwj on IRC: - PID file creation was never enabled for Windows, as the `pid_t` filetype is not available for it. However, the WIN32 API contains the header [`Processthreadsapi.h`](https://github.com/CodeShark/x86_64-w64-mingw32/blob/master/include/processthreadsapi.h) which in turn contains the function [`GetCurrentProcessId()`](https://docs.microsoft.com/en-gb/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getcurrentprocessid). ~~This function is called at a higher level by [`_getpid()`](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getpid?view=vs-2017)~~ EDIT: `_getpid()` is not available to the MSVC compiler used in the AppVeyor build. As a result, I have changed the function call to`GetCurrentProcessId()`, which performs the same function and is available to both MinGW & MSVC. This allows one to capture the PID in Windows, without any additional includes - the above function is already available. - Within this PR, I have added a separate line that calls `GetCurrentProcessId()` in the case of a WIN compilation, and the usual `getpid()` otherwise. All code blocks processing PID file logic that avoid WIN32 have been changed to consider it. I have also updated the preprocessor definitions in `libbitcoin_server.vcxproj.in` to suppress a warning related to `std::strerror` for the MSVC build, that was causing the AppVeyor build to fail (see @fanquake comment below). # Rationale - Consistency between OS's running Bitcoin - Applications which build off of `bitcoind`, such as novel front-end clients, often need access to the PID in order to control the daemon. Instead of designing some alternate way of doing this for one system, it should be consistent between all of them. In collaboration with @joernroeder Tree-SHA512: 22fcbf866e99115d12ed29716e68d200d4c118ae2f7b188b7705dc0cf5f0cd0ce5fb18f772744c6238eecd9e6d0922c615e2f0e12a7fe7c810062a79d97aa6a2

Introduction
As discussed with @laanwj on IRC:
PID file creation was never enabled for Windows, as the
pid_tfiletype is not available for it. However, the WIN32 API contains the headerProcessthreadsapi.hwhich in turn contains the functionGetCurrentProcessId().This function is called at a higher level byEDIT:_getpid()_getpid()is not available to the MSVC compiler used in the AppVeyor build. As a result, I have changed the function call toGetCurrentProcessId(), which performs the same function and is available to both MinGW & MSVC.This allows one to capture the PID in Windows, without any additional includes - the above function is already available.
Within this PR, I have added a separate line that calls
GetCurrentProcessId()in the case of a WIN compilation, and the usualgetpid()otherwise. All code blocks processing PID file logic that avoid WIN32 have been changed to consider it. I have also updated the preprocessor definitions inlibbitcoin_server.vcxproj.into suppress a warning related tostd::strerrorfor the MSVC build, that was causing the AppVeyor build to fail (see @fanquake comment below).Rationale
bitcoind, such as novel front-end clients, often need access to the PID in order to control the daemon. Instead of designing some alternate way of doing this for one system, it should be consistent between all of them.In collaboration with @joernroeder