chgserver: deal with fdopen EINVAL case

Summary:
The use of `fdopen` was to change the buffer size. It's not fatal if buffer
size cannot be changed. This fixes a crash in `nohup hg root`.

Reviewed By: aditya7fb

Differential Revision: D17628883

fbshipit-source-id: 58f75e8e99fbe4cea8da2e3b48a092ee1331db6f
This commit is contained in:
Jun Wu 2019-09-27 09:43:34 -07:00 committed by Facebook Github Bot
parent 6cb28d027c
commit 7f3b4d93e9

View File

@ -218,7 +218,12 @@ class chgcmdserver(commandserver.server):
bufsize = 1 # line buffered
else:
bufsize = -1 # system default
newfp = util.fdopen(fp.fileno(), mode, bufsize)
try:
newfp = util.fdopen(fp.fileno(), mode, bufsize)
except OSError:
# fdopen can fail with EINVAL. For example, run
# with nohup. Do not set buffer size in that case.
newfp = fp
setattr(ui, fn, newfp)
setattr(self, cn, newfp)