[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-10-12 Thread STINNER Victor
STINNER Victor added the comment: > Did you encounter this in real life? Well, my initial concern was that dup() creates an inheritable file descriptor. It is unlikely that fork() occurs while is_valid_fd() is called, because is_valid_fd() is only called early during Python initialization. Re

[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-08-23 Thread Tshepang Lekhonkhobe
Changes by Tshepang Lekhonkhobe : -- nosy: +tshepang ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-08-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Thanks. I guess is_valid_fd() could be improved to check for EBADF, but other than that I don't see the problem. dup() is better than fstat() which may do some actual I/O. Did you encounter this in real life? -- ___

[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-08-21 Thread STINNER Victor
STINNER Victor added the comment: > By the way, can you please mention the actual changeset id? (not only the > parent) Oh, I failed to copy/paste the changeset, sorry :-) It is the changeset f15943505db0: changeset: 73775:f15943505db0 branch: 3.2 parent: 73773:661fb211f220 user:

[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-08-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: By the way, can you please mention the actual changeset id? (not only the parent) -- ___ Python tracker ___ ___

[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-08-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: > > Why should it? > > fstat() does not need to create a new file descriptor. Creating a new > file descriptor can fail (ex: limit of the number of open files). Why should I care? fstat() can fail too. The only important thing is whether dup() returns EBADF or

[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-08-21 Thread STINNER Victor
STINNER Victor added the comment: > Why should it? fstat() does not need to create a new file descriptor. Creating a new file descriptor can fail (ex: limit of the number of open files). -- ___ Python tracker ___

[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-08-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: > is_valid_fd() of Python/pythorun.c should use fstat() to check if a > file descriptor is valid, instead of duplicating it using dup() (and > then closing it). Why should it? fstat() may be expensive, while dup() is cheap. -- _

[issue18804] pythorun.c: is_valid_fd() should not duplicate the file descriptor

2013-08-21 Thread STINNER Victor
New submission from STINNER Victor: is_valid_fd() of Python/pythorun.c should use fstat() to check if a file descriptor is valid, instead of duplicating it using dup() (and then closing it). If Windows needs a special check, it would be better to run checks on the handle of the file descripto