提交 c569b1fe 编写于 作者: R René Scharfe 提交者: Junio C Hamano

daemon: handle freopen() failure

Die if stderr couldn't be sent to /dev/null when operating in inetd
mode and report the error message from the OS.

This fixes a compiler warning about the return value of freopen()
being ignored on Ubuntu 8.10.
Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 8104ebfe
......@@ -1118,7 +1118,9 @@ int main(int argc, char **argv)
struct sockaddr *peer = (struct sockaddr *)&ss;
socklen_t slen = sizeof(ss);
freopen("/dev/null", "w", stderr);
if (!freopen("/dev/null", "w", stderr))
die("failed to redirect stderr to /dev/null: %s",
strerror(errno));
if (getpeername(0, peer, &slen))
peer = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册