Skip to content

Commit

Permalink
allow c stdin & stderr when running in cmd.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
skywind3000 committed Feb 8, 2022
1 parent d7ee9cf commit 31a0ca5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions PyStand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,15 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int show)
return 3;
}
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
#if 0
#ifdef _MSC_VER
freopen_s("CONOUT$", "w", stdout);
freopen_s("CONOUT$", "w", stderr);
freopen_s("CONIN$", "r", stdin);
#else
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin);
#endif
int fd = fileno(stdout);
if (fd >= 0) {
std::string fn = std::to_string(fd);
Expand All @@ -339,7 +344,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int show)
std::string fn = std::to_string(fd);
SetEnvironmentVariableA("PYSTAND_STDIN", fn.c_str());
}
#endif
}
int hr = ps.RunString(init_script);
// printf("finalize\n");
Expand Down

0 comments on commit 31a0ca5

Please sign in to comment.