Files
monok8s/patches/ask/cmm/0002-cmm-support-stdout-log-target.patch
2026-05-11 02:13:10 +08:00

37 lines
1.1 KiB
Diff

From 787cf734c807eecc479776ab6ac5c2c43c72e93d Mon Sep 17 00:00:00 2001
From: Patch <patch@example.com>
Date: Sun, 10 May 2026 17:37:49 +0000
Subject: [PATCH] cmm: support stdout log target
diff --git a/cmm/src/ffcontrol.c b/cmm/src/ffcontrol.c
index 4c9bdf1..b2b6b53 100644
--- a/cmm/src/ffcontrol.c
+++ b/cmm/src/ffcontrol.c
@@ -19,6 +19,7 @@
#include <string.h>
#include <signal.h>
#include <ctype.h>
+#include <unistd.h>
/* bits/sockaddr.h is glibc internal, use sys/socket.h (already included) */
#include <asm/types.h>
@@ -865,7 +866,13 @@ static int section_logging_option_hdlr(void *data, int argc, char **argv)
if (!strcasecmp(option, "file"))
{
- globalConf.logFile = fopen(value, "a");
+ if (!strcasecmp(value, "stdout") || !strcmp(value, "-"))
+ globalConf.logFile = fdopen(dup(STDOUT_FILENO), "a");
+ else if (!strcasecmp(value, "stderr"))
+ globalConf.logFile = fdopen(dup(STDERR_FILENO), "a");
+ else
+ globalConf.logFile = fopen(value, "a");
+
if (!globalConf.logFile)
{
cmm_print(DEBUG_CRIT, "cmmFcParser: Opening logfile %s returned error %s.\n", value, strerror(errno));
--
2.47.3