Skip to content

Commit

Permalink
Merge pull request #3 from jenatali/patch-2
Browse files Browse the repository at this point in the history
Improve reliability in the face of fork/exec
  • Loading branch information
iourit authored Sep 28, 2021
2 parents 2dba0ba + 1aad8aa commit bf4f9b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/d3dkmt-wsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#define RETURN_IF_NTSTATUS_FAILED(expr) do { NTSTATUS __statusRet = (expr); if (!NT_SUCCESS(__statusRet)) { return __statusRet; }} while (0)

int DxgFd = open("/dev/dxg", O_RDONLY);
int DxgFd = open("/dev/dxg", O_RDONLY | O_CLOEXEC);

NTSTATUS LinuxErrToNTSTATUS(int err)
{
Expand Down Expand Up @@ -54,6 +54,11 @@ NTSTATUS LinuxErrToNTSTATUS(int err)
if (DxgFd == -1) \
return STATUS_UNSUCCESSFUL; \
int ioctlret = ioctl(DxgFd, _IOWR('G', IoctlId, ARGSSTRUCT), pArgs); \
if (ioctlret == -1 && (errno == ENOTTY || errno == EBADF)) { \
close(DxgFd); \
DxgFd = open("/dev/dxg", O_RDONLY | O_CLOEXEC); \
ioctlret = ioctl(DxgFd, _IOWR('G', IoctlId, ARGSSTRUCT), pArgs); \
} \
if (ioctlret == -1) return LinuxErrToNTSTATUS(errno); \
return ioctlret; \
}
Expand Down

0 comments on commit bf4f9b6

Please sign in to comment.