Skip to content

Commit

Permalink
[fix] All pipy processes mistakenly shared the same stdio pipes on Wi…
Browse files Browse the repository at this point in the history
…ndows
  • Loading branch information
pajama-coder committed Sep 22, 2024
1 parent dac72fb commit a7a614f
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/os-platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,31 +272,27 @@ void kill(int pid, int sig) {

auto FileHandle::std_input() -> FileHandle {
if (!s_stdin_server) {
s_stdin_server = new StdioServer(
GetStdHandle(STD_INPUT_HANDLE),
"\\\\.\\pipe\\pipy.stdin",
true
);
char name[256];
std::snprintf(name, sizeof(name), "\\\\.\\pipe\\pipy.stdin\\%08x", GetCurrentProcessId());
s_stdin_server = new StdioServer(GetStdHandle(STD_INPUT_HANDLE), name, true);
}
return FileHandle(s_stdin_server->connect());
}

auto FileHandle::std_output() -> FileHandle {
if (!s_stdout_server) {
s_stdout_server = new StdioServer(
GetStdHandle(STD_OUTPUT_HANDLE),
"\\\\.\\pipe\\pipy.stdout"
);
char name[256];
std::snprintf(name, sizeof(name), "\\\\.\\pipe\\pipy.stdout\\%08x", GetCurrentProcessId());
s_stdout_server = new StdioServer(GetStdHandle(STD_OUTPUT_HANDLE), name);
}
return FileHandle(s_stdout_server->connect());
}

auto FileHandle::std_error() -> FileHandle {
if (!s_stderr_server) {
s_stderr_server = new StdioServer(
GetStdHandle(STD_ERROR_HANDLE),
"\\\\.\\pipe\\pipy.stderr"
);
char name[256];
std::snprintf(name, sizeof(name), "\\\\.\\pipe\\pipy.stderr\\%08x", GetCurrentProcessId());
s_stderr_server = new StdioServer(GetStdHandle(STD_ERROR_HANDLE), name);
}
return FileHandle(s_stderr_server->connect());
}
Expand Down

0 comments on commit a7a614f

Please sign in to comment.