Gracefully handle stdin flush failure on BSD

Catches an IOError that is thrown when starting Swift on BSD-based
platforms, as the underlying system call to flush returns errno 9 (bad
file descriptor), whereas on Linux it succeeds.
Change-Id: Ic143d2fe6c3e1e0b39794958b40b0f5efdc17c06
This commit is contained in:
Brian Cline
2012年09月21日 11:17:35 -05:00
parent 8a7afa535f
commit 87c1c5dce9

View File

@@ -685,7 +685,12 @@ def capture_stdio(logger, **kwargs):
with open(os.devnull, 'r+b') as nullfile:
# close stdio (excludes fds open for logging)
for f in stdio_files:
f.flush()
# some platforms throw an error when attempting an stdin flush
try:
f.flush()
except IOError:
pass
try:
os.dup2(nullfile.fileno(), f.fileno())
except OSError:
Reference in New Issue
openstack/swift
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.