git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix condition for redirecting stderr

From
Lucas Werkmeister <mail@lucaswerkmeister.de>
Date
Apr 3, 2018, 22:13 UTC
Message-ID
<20180403221307.29194-1-mail@lucaswerkmeister.de>

Since the --log-destination option was added in 0c591cacb ("daemon: add --log-destination=(stderr|syslog|none)", 2018-02-04) with the explicit goal of allowing logging to stderr when running in inetd mode, we should not always redirect stderr to /dev/null in inetd mode, but rather only when stderr is not being used for logging.

Signed-off-by: Lucas Werkmeister <mail@lucaswerkmeister.de>
---
Notes:
    I have to apologize to the list here… even though I proposed this
    option with the goal of using it on my server, for some reason I
    decided to only use it there after the next Git release had come
    out, and didn’t test it anywhere else. The code looked okay, but I
    missed this part near the end of daemon.c that made it ineffective,
    rendering the feature broken in the 2.17.0 release and making me
    look like an idiot :/ sorry, everyone.
    
    For what it’s worth, with this fix the feature appears to work as
    intended (I *have* tested it on my server now and log messages from
    git-daemon show up in the journal as intended, attributed to the
    correct unit and everything).
 daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon.c b/daemon.c
index fe833ea7d..9d2e0d20e 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1459,7 +1459,7 @@ int cmd_main(int argc, const char **argv)
 		die("base-path '%s' does not exist or is not a directory",
 		    base_path);
 
-	if (inetd_mode) {
+	if (log_destination != LOG_DESTINATION_STDERR) {
 		if (!freopen("/dev/null", "w", stderr))
 			die_errno("failed to redirect stderr to /dev/null");
 	}
-- 
2.16.3
Next: Todd Zullinger
Message 1 of 3 in “Fix condition for redirecting stderr”
  1. Fix condition for redirecting stderrLucas Werkmeister, Apr 3, 2018
  2. Todd ZullingerApr 9, 2018
  3. Lucas WerkmeisterApr 9, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.