Skip to content

Commit

Permalink
Move err_close_fds adds next to pipe creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
gpshead committed Oct 7, 2022
1 parent 99c03e9 commit 4345a1a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Lib/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,8 +1347,8 @@ def _get_handles(self, stdin, stdout, stderr):
if p2cread is None:
p2cread, _ = _winapi.CreatePipe(None, 0)
p2cread = Handle(p2cread)
_winapi.CloseHandle(_)
err_close_fds.append(p2cread)
_winapi.CloseHandle(_)
elif stdin == PIPE:
p2cread, p2cwrite = _winapi.CreatePipe(None, 0)
p2cread, p2cwrite = Handle(p2cread), Handle(p2cwrite)
Expand All @@ -1367,8 +1367,8 @@ def _get_handles(self, stdin, stdout, stderr):
if c2pwrite is None:
_, c2pwrite = _winapi.CreatePipe(None, 0)
c2pwrite = Handle(c2pwrite)
_winapi.CloseHandle(_)
err_close_fds.append(c2pwrite)
_winapi.CloseHandle(_)
elif stdout == PIPE:
c2pread, c2pwrite = _winapi.CreatePipe(None, 0)
c2pread, c2pwrite = Handle(c2pread), Handle(c2pwrite)
Expand All @@ -1387,8 +1387,8 @@ def _get_handles(self, stdin, stdout, stderr):
if errwrite is None:
_, errwrite = _winapi.CreatePipe(None, 0)
errwrite = Handle(errwrite)
_winapi.CloseHandle(_)
err_close_fds.append(errwrite)
_winapi.CloseHandle(_)
elif stderr == PIPE:
errread, errwrite = _winapi.CreatePipe(None, 0)
errread, errwrite = Handle(errread), Handle(errwrite)
Expand Down Expand Up @@ -1678,9 +1678,9 @@ def _get_handles(self, stdin, stdout, stderr):
pass
elif stdin == PIPE:
p2cread, p2cwrite = os.pipe()
err_close_fds.extend((p2cread, p2cwrite))
if self.pipesize > 0 and hasattr(fcntl, "F_SETPIPE_SZ"):
fcntl.fcntl(p2cwrite, fcntl.F_SETPIPE_SZ, self.pipesize)
err_close_fds.extend((p2cread, p2cwrite))
elif stdin == DEVNULL:
p2cread = self._get_devnull()
elif isinstance(stdin, int):
Expand All @@ -1693,9 +1693,9 @@ def _get_handles(self, stdin, stdout, stderr):
pass
elif stdout == PIPE:
c2pread, c2pwrite = os.pipe()
err_close_fds.extend((c2pread, c2pwrite))
if self.pipesize > 0 and hasattr(fcntl, "F_SETPIPE_SZ"):
fcntl.fcntl(c2pwrite, fcntl.F_SETPIPE_SZ, self.pipesize)
err_close_fds.extend((c2pread, c2pwrite))
elif stdout == DEVNULL:
c2pwrite = self._get_devnull()
elif isinstance(stdout, int):
Expand All @@ -1708,9 +1708,9 @@ def _get_handles(self, stdin, stdout, stderr):
pass
elif stderr == PIPE:
errread, errwrite = os.pipe()
err_close_fds.extend((errread, errwrite))
if self.pipesize > 0 and hasattr(fcntl, "F_SETPIPE_SZ"):
fcntl.fcntl(errwrite, fcntl.F_SETPIPE_SZ, self.pipesize)
err_close_fds.extend((errread, errwrite))
elif stderr == STDOUT:
if c2pwrite != -1:
errwrite = c2pwrite
Expand Down

0 comments on commit 4345a1a

Please sign in to comment.