add support for the standard error stream in the Run class

This commit is contained in:
tomasz.sowa committed 2026-11-23 20:37:50 +01:00
1 parent 7a16230a5c
commit c9fd6c1a32
2 files changed
+62 -28

No files matched your search

+13 -7
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2011-2018, Tomasz Sowa
/*
* Copyright (c) 2011-2026, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -132,6 +132,11 @@ public:
int Go(std::string & out);
int Go();
/*
* with standard error
*/
int Go(const char * in, std::string & out, std::string & err_out);
/*
last status:
@@ -158,16 +163,16 @@ public:
private:
int Go(const char * in, size_t inlen, std::string * out);
int Go(const char * in, size_t inlen, std::string * out, std::string * err_out);
void SetName();
void CheckStatus();
void WriteRead(const char * in, size_t inlen, std::string * out);
void WriteRead(const char * in, size_t inlen, std::string * out, std::string * err_out);
bool CreatePipes();
bool Fork();
void ChildThrow();
void Child();
void Write(const char * in, size_t inlen);
void Read(std::string & out);
void Read(std::string & out, int descriptor);
int last_status;
@@ -176,8 +181,9 @@ private:
// if last_status!=0 then last_return is 255
int last_return;
int desin[2];
int desout[2];
int desin[2]; // standard otput: the child writes to desin[1], the parent reads from desin[0]
int desin_err[2]; // standard error output: the child writes to desin_err[1], the parent reads from desin_err[0]
int desout[2]; // standard input: the parent writes to desout[1], the child reads from desout[0]
char * par[WINIX_RUN_MAX_PARAMETERS + 2];
char * env[WINIX_RUN_MAX_PARAMETERS + 1];