I have a c++ program that runs under Apache24 cgi-bin on Windows 11. No problems so far.
I want this program to either A) attach to an existing named mapped file to send stuff to a previously started console application or B) start the console application (w/DETACHED_PROCESS) and then map to the file the created process just created. Events and mutexes sync everything.
The mapped file is used to pass complex messages back and forth.
The problem is that when the C++ program creates the process running under Apache24, the created process has no console window. When the same code runs in debug mode from Visual Studio 2022, it works fine and it does have a console window.
The created process starts off with the following:
bool console_created = AllocConsole();
if (console_created) {
FILE* fpstdin = stdin, * fpstdout = stdout, * fpstderr = stderr;
freopen_s(&fpstdin, "CONIN$", "r", stdin);
freopen_s(&fpstdout, "CONOUT$", "w", stdout);
freopen_s(&fpstderr, "CONOUT$", "w", stderr);
}
So the jist of my question is why does it work under VS and not under Apache?
I don’t know off the top of my head what Apache is using for an account. VS is running under my desktop user account.
Under Apache, the process is being started but the anticipated result from AllocConsole + freopen() isn’t happening. Also, if the detached process is already running via VS, the cgi program doesn’t see the named mapped file and it starts a 2nd instance of the detached process.
I’m pretty meticulous about checking return status from every call and everything claims to be OK.
Debugging the program running under Apache is tedious to say the least. I’ve created a log file of the launch process but it hasn’t produced any useful information.