fixup! win: use PROC_THREAD_ATTRIBUTE_HANDLE_LIST in uv_spawn
This commit is contained in:
parent
0d4acd733b
commit
afb8fd2bdd
@ -1047,7 +1047,10 @@ int uv_spawn(uv_loop_t* loop,
|
|||||||
* inherited, closing the race condition where concurrent uv_spawn calls
|
* inherited, closing the race condition where concurrent uv_spawn calls
|
||||||
* could cause handles intended for one child to leak into another. */
|
* could cause handles intended for one child to leak into another. */
|
||||||
{
|
{
|
||||||
int count = uv__stdio_size(child_stdio_buffer);
|
#define CHILD_STDIO_COUNT(buffer) \
|
||||||
|
*((unsigned int*) (buffer))
|
||||||
|
int count = CHILD_STDIO_COUNT(child_stdio_buffer);
|
||||||
|
#undef CHILD_STDIO_COUNT
|
||||||
int n = 0;
|
int n = 0;
|
||||||
SIZE_T attr_size = 0;
|
SIZE_T attr_size = 0;
|
||||||
|
|
||||||
|
|||||||
@ -211,25 +211,18 @@ static int maybe_run_test(int argc, char **argv) {
|
|||||||
if (strcmp(argv[1], "spawn_helper8") == 0) {
|
if (strcmp(argv[1], "spawn_helper8") == 0) {
|
||||||
uv_os_fd_t closed_fd;
|
uv_os_fd_t closed_fd;
|
||||||
uv_os_fd_t open_fd;
|
uv_os_fd_t open_fd;
|
||||||
#ifdef _WIN32
|
|
||||||
DWORD flags;
|
|
||||||
HMODULE kernelbase_module;
|
|
||||||
union {
|
|
||||||
FARPROC proc;
|
|
||||||
sCompareObjectHandles pCompareObjectHandles; /* Windows >= 10 */
|
|
||||||
} u;
|
|
||||||
#endif
|
|
||||||
notify_parent_process();
|
notify_parent_process();
|
||||||
ASSERT_EQ(sizeof(closed_fd), read(0, &closed_fd, sizeof(closed_fd)));
|
ASSERT_EQ(sizeof(closed_fd), read(0, &closed_fd, sizeof(closed_fd)));
|
||||||
ASSERT_EQ(sizeof(open_fd), read(0, &open_fd, sizeof(open_fd)));
|
ASSERT_EQ(sizeof(open_fd), read(0, &open_fd, sizeof(open_fd)));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
DWORD flags;
|
||||||
ASSERT_GT((intptr_t) closed_fd, 0);
|
ASSERT_GT((intptr_t) closed_fd, 0);
|
||||||
ASSERT_GT((intptr_t) open_fd, 0);
|
ASSERT_GT((intptr_t) open_fd, 0);
|
||||||
ASSERT_NE(0, GetHandleInformation(open_fd, &flags));
|
ASSERT_EQ(0, GetHandleInformation(open_fd, &flags));
|
||||||
kernelbase_module = GetModuleHandleW(L"kernelbase.dll");
|
ASSERT_EQ(ERROR_INVALID_HANDLE, GetLastError());
|
||||||
u.proc = GetProcAddress(kernelbase_module, "CompareObjectHandles");
|
SetLastError(ERROR_SUCCESS);
|
||||||
if (u.pCompareObjectHandles != NULL)
|
ASSERT_EQ(0, GetHandleInformation(closed_fd, &flags));
|
||||||
ASSERT_EQ(FALSE, u.pCompareObjectHandles(open_fd, closed_fd));
|
ASSERT_EQ(ERROR_INVALID_HANDLE, GetLastError());
|
||||||
#else
|
#else
|
||||||
ASSERT_GT(open_fd, 2);
|
ASSERT_GT(open_fd, 2);
|
||||||
ASSERT_GT(closed_fd, 2);
|
ASSERT_GT(closed_fd, 2);
|
||||||
|
|||||||
@ -1677,11 +1677,6 @@ TEST_IMPL(spawn_fs_open) {
|
|||||||
uv_stdio_container_t stdio[1];
|
uv_stdio_container_t stdio[1];
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const char dev_null[] = "NUL";
|
const char dev_null[] = "NUL";
|
||||||
HMODULE kernelbase_module;
|
|
||||||
union {
|
|
||||||
FARPROC proc;
|
|
||||||
sCompareObjectHandles pCompareObjectHandles; /* Windows >= 10 */
|
|
||||||
} u;
|
|
||||||
#else
|
#else
|
||||||
const char dev_null[] = "/dev/null";
|
const char dev_null[] = "/dev/null";
|
||||||
#endif
|
#endif
|
||||||
@ -1704,10 +1699,6 @@ TEST_IMPL(spawn_fs_open) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ASSERT_NE(0, DuplicateHandle(GetCurrentProcess(), fd, GetCurrentProcess(), &dup_fd,
|
ASSERT_NE(0, DuplicateHandle(GetCurrentProcess(), fd, GetCurrentProcess(), &dup_fd,
|
||||||
0, /* inherit */ TRUE, DUPLICATE_SAME_ACCESS));
|
0, /* inherit */ TRUE, DUPLICATE_SAME_ACCESS));
|
||||||
kernelbase_module = GetModuleHandleW(L"kernelbase.dll");
|
|
||||||
u.proc = GetProcAddress(kernelbase_module, "CompareObjectHandles");
|
|
||||||
if (u.pCompareObjectHandles != NULL)
|
|
||||||
ASSERT_EQ(TRUE, u.pCompareObjectHandles(fd, dup_fd));
|
|
||||||
#else
|
#else
|
||||||
dup_fd = dup(fd);
|
dup_fd = dup(fd);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user