mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #12105: Add O_CLOEXEC to the os module.
This commit is contained in:
parent
f738d33e5d
commit
1e045b1831
4 changed files with 13 additions and 0 deletions
|
@ -9,6 +9,7 @@ import errno
|
|||
import sys
|
||||
import time
|
||||
import os
|
||||
import fcntl
|
||||
import pwd
|
||||
import shutil
|
||||
import stat
|
||||
|
@ -307,6 +308,12 @@ class PosixTester(unittest.TestCase):
|
|||
fp1.close()
|
||||
fp2.close()
|
||||
|
||||
@unittest.skipUnless(hasattr(os, 'O_CLOEXEC'), "needs os.O_CLOEXEC")
|
||||
def test_oscloexec(self):
|
||||
fd = os.open(support.TESTFN, os.O_RDONLY|os.O_CLOEXEC)
|
||||
self.addCleanup(os.close, fd)
|
||||
self.assertTrue(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC)
|
||||
|
||||
def test_osexlock(self):
|
||||
if hasattr(posix, "O_EXLOCK"):
|
||||
fd = os.open(support.TESTFN,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue