Bläddra i källkod

Make file in fd_open_for_write inheritable on Windows

rexim 4 år sedan
förälder
incheckning
f48e22ea3d
1 ändrade filer med 5 tillägg och 1 borttagningar
  1. 5 1
      nobuild2.h

+ 5 - 1
nobuild2.h

@@ -531,11 +531,15 @@ Fd fd_open_for_write(Cstr path)
     }
     }
     return result;
     return result;
 #else
 #else
+    SECURITY_ATTRIBUTES saAttr = {0};
+    saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
+    saAttr.bInheritHandle = TRUE;
+
     Fd result = CreateFile(
     Fd result = CreateFile(
                     path,                // name of the write
                     path,                // name of the write
                     GENERIC_WRITE,          // open for writing
                     GENERIC_WRITE,          // open for writing
                     0,                      // do not share
                     0,                      // do not share
-                    NULL,                   // default security
+                    &saAttr,                   // default security
                     CREATE_NEW,             // create new file only
                     CREATE_NEW,             // create new file only
                     FILE_ATTRIBUTE_NORMAL,  // normal file
                     FILE_ATTRIBUTE_NORMAL,  // normal file
                     NULL                  // no attr. template
                     NULL                  // no attr. template