This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dhamilton
Recipients dhamilton, paul.moore, steve.dower, tim.golden, zach.ware
Date 2020-01-15.18:55:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579114556.26.0.996943969176.issue39345@roundup.psfhosted.org>
In-reply-to
Content
This is related to https://bugs.python.org/issue17797, which is closed.

Using Python 3.7.4, Windows 10.0.18362, Visual Studio 2017 and running as a C Application.  Py_Initialize() eventually calls is_valid_fd with STDIN.  The behavior appears to cause both dup() and fstat() to hang indefinitely (using RELEASE MSVCRT DLLs, it works correctly using MSVCRT Debug DLLs).  The call stack shows Windows is waiting for some Windows Event.  The recommended patch in issue17797 will not work.

is_valid_fd appears to want to read the 'input' using a file descriptor.  since both dup and fstat hang, I realized that isatty() would indicate if the file descriptor is valid and works for any predefined FD descriptor(STDIN-0, STDOUT-1, STDERR-2).

#if defined(MS_WINDOWS)
	struct stat buf;
	if (fd >= fileno(stdin) && fd <= fileno(stderr)) {
		return (_isatty(fd) == 0 && errno == EBADF) ? 0 : 1;
	}
	else if (fstat(fd, &buf) < 0 && (errno == EBADF || errno == ENOENT))
		return 0;
	return 1;
#else
History
Date User Action Args
2020-01-15 18:55:56dhamiltonsetrecipients: + dhamilton, paul.moore, tim.golden, zach.ware, steve.dower
2020-01-15 18:55:56dhamiltonsetmessageid: <1579114556.26.0.996943969176.issue39345@roundup.psfhosted.org>
2020-01-15 18:55:56dhamiltonlinkissue39345 messages
2020-01-15 18:55:55dhamiltoncreate