mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-14 01:58:25 +00:00
[host] windows: fix stdout/stderr resource leak
This commit is contained in:
parent
cd6485f2ed
commit
7321ca6768
@ -66,6 +66,9 @@ struct AppState
|
|||||||
HANDLE exitWait;
|
HANDLE exitWait;
|
||||||
HANDLE taskHandle;
|
HANDLE taskHandle;
|
||||||
|
|
||||||
|
FILE * stdErrFile;
|
||||||
|
FILE * stdOutFile;
|
||||||
|
|
||||||
_Atomic(bool) hasPendingActivationRequest;
|
_Atomic(bool) hasPendingActivationRequest;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -349,10 +352,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
int std_out_fd = _open_osfhandle((intptr_t)std_out, _O_TEXT);
|
int std_out_fd = _open_osfhandle((intptr_t)std_out, _O_TEXT);
|
||||||
|
|
||||||
if (std_err_fd > 0)
|
if (std_err_fd > 0)
|
||||||
*stderr = *_fdopen(std_err_fd, "w");
|
{
|
||||||
|
app.stdErrFile = _fdopen(std_err_fd, "w");
|
||||||
|
*stderr = *app.stdErrFile;
|
||||||
|
}
|
||||||
|
|
||||||
if (std_out_fd > 0)
|
if (std_out_fd > 0)
|
||||||
*stdout = *_fdopen(std_out_fd, "w");
|
{
|
||||||
|
app.stdOutFile = _fdopen(std_out_fd, "w");
|
||||||
|
*stdout = *app.stdOutFile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -474,6 +483,12 @@ finish:
|
|||||||
if (app.taskHandle)
|
if (app.taskHandle)
|
||||||
AvRevertMmThreadCharacteristics(app.taskHandle);
|
AvRevertMmThreadCharacteristics(app.taskHandle);
|
||||||
|
|
||||||
|
if (app.stdErrFile)
|
||||||
|
fclose(app.stdErrFile);
|
||||||
|
|
||||||
|
if (app.stdOutFile)
|
||||||
|
fclose(app.stdOutFile);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user