Skip to content

Commit

Permalink
windows exec fix
Browse files Browse the repository at this point in the history
  • Loading branch information
novemus committed Dec 23, 2023
1 parent b6765b0 commit a73bbfa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ The [plexus](https://github.com/novemus/plexus) tool is designed to make the pos

## Build

You can download [prebuild packages](https://github.com/novemus/plexus/releases) for Debian and Windows platforms.

The project depends on `boost` and `openssl` libraries. Clone repository and run make command.

```console
Expand Down
13 changes: 10 additions & 3 deletions exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void exec(const std::string& prog, const std::string& args, const std::string& d

std::memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
si.dwFlags |= STARTF_USESTDHANDLES;
std::memset(&pi, 0, sizeof(pi));

if (!log.empty())
Expand All @@ -54,12 +55,18 @@ void exec(const std::string& prog, const std::string& args, const std::string& d
if (h == INVALID_HANDLE_VALUE)
throw std::runtime_error(utils::format("CreateFile: error=%d", GetLastError()));

si.dwFlags |= STARTF_USESTDHANDLES;
si.hStdError = h;
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
si.hStdOutput = h;
si.hStdError = h;
}
else
{
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
}

if (CreateProcess(prog.c_str(), (char*)cmd.c_str(), 0, 0, true, CREATE_NO_WINDOW, 0, dir.empty() ? 0 : dir.c_str(), &si, &pi))
if (CreateProcess(prog.c_str(), (char*)cmd.c_str(), 0, 0, true, 0, 0, dir.empty() ? 0 : dir.c_str(), &si, &pi))
{
WaitForSingleObject(pi.hProcess, INFINITE);

Expand Down
2 changes: 1 addition & 1 deletion wormhole
Submodule wormhole updated 6 files
+4 −1 CMakeLists.txt
+2 −0 README.md
+208 −0 tests/wormhole.cpp
+1 −1 tubus
+38 −54 wormhole.cpp
+0 −1 wormhole.h

0 comments on commit a73bbfa

Please sign in to comment.