@@ -26,24 +26,35 @@ using namespace std::literals::chrono_literals;
2626
2727MyShell::MyShell (std::string command) :
2828 procHasExited(false ),
29+ stopSignal(false ),
2930 procExitCode(0 ),
30- stopSignal(false )
31+ outputBuffer(" " ),
32+ errorBuffer(" " ),
33+ outputMutex(),
34+ errorMutex(),
35+ outputReader(std::thread(
36+ &MyShell::outputReaderThread,
37+ this
38+ )),
39+ errorReader(std::thread(
40+ &MyShell::errorReaderThread,
41+ this
42+ )),
43+ #ifdef _WIN32
44+ procHandle (0 ),
45+ inputWriteHandle(0 ),
46+ outputReadHandle(0 ),
47+ errorReadHandle(0 ),
48+ procId(0 )
49+ #else
50+ procId (0 )
51+ #endif
3152{
3253 #ifdef _WIN32
3354 this ->createWindowsProcess (command);
3455 #else
3556 this ->createUnixProcess (command);
3657 #endif
37-
38- this ->outputReader = std::thread (
39- &MyShell::outputReaderThread,
40- this
41- );
42-
43- this ->errorReader = std::thread (
44- &MyShell::errorReaderThread,
45- this
46- );
4758}
4859
4960MyShell::~MyShell () {
@@ -145,7 +156,9 @@ void MyShell::readFromPipe(HANDLE pipe, std::string& buffer, std::mutex& mutex)
145156 buffer += tempBuffer.data ();
146157 }
147158 }
148- else std::this_thread::sleep_for (10ms);
159+ else std::this_thread::sleep_for (
160+ std::chrono::milliseconds (10 )
161+ );
149162 }
150163}
151164
@@ -220,7 +233,9 @@ void MyShell::readFromPipe(int pipe, std::string& buffer, std::mutex& mutex) {
220233 buffer += tempBuffer.data ();
221234 }
222235 else if (bytesRead == -1 && errno == EAGAIN)
223- std::this_thread::sleep_for (10ms);
236+ std::this_thread::sleep_for (
237+ std::chrono::milliseconds (10 )
238+ );
224239 }
225240}
226241
0 commit comments