1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 17:31:47 +02:00

Clean up standard stream logic

Now we have enough portability stuff
This commit is contained in:
John Ericson 2024-11-07 13:15:03 -05:00
parent 0ed5af164f
commit 372353722e
9 changed files with 44 additions and 18 deletions

View file

@ -106,8 +106,25 @@ void drainFD(
#endif
);
/**
* Get [Standard Input](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin))
*/
[[gnu::always_inline]]
inline Descriptor getStandardOut() {
inline Descriptor getStandardInput()
{
#ifndef _WIN32
return STDIN_FILENO;
#else
return GetStdHandle(STD_INPUT_HANDLE);
#endif
}
/**
* Get [Standard Output](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout))
*/
[[gnu::always_inline]]
inline Descriptor getStandardOutput()
{
#ifndef _WIN32
return STDOUT_FILENO;
#else
@ -115,6 +132,19 @@ inline Descriptor getStandardOut() {
#endif
}
/**
* Get [Standard Error](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr))
*/
[[gnu::always_inline]]
inline Descriptor getStandardError()
{
#ifndef _WIN32
return STDERR_FILENO;
#else
return GetStdHandle(STD_ERROR_HANDLE);
#endif
}
/**
* Automatic cleanup of resources.
*/