Added cmm image

This commit is contained in:
2026-05-11 02:13:10 +08:00
parent e0bb9d72a4
commit dca01e4abf
8 changed files with 206 additions and 6 deletions

View File

@@ -0,0 +1,75 @@
From 7b6ff0e4a7b5e7d422c787d55225ecaa32afc8e4 Mon Sep 17 00:00:00 2001
From: Mono <dev@mono>
Date: Sun, 10 May 2026 15:53:21 +0000
Subject: [PATCH] cmm: add foreground mode
---
cmm/src/cmm.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/cmm/src/cmm.c b/cmm/src/cmm.c
index 6452476..1bbc73e 100644
--- a/cmm/src/cmm.c
+++ b/cmm/src/cmm.c
@@ -339,6 +339,7 @@ int main (int argc, char ** argv)
struct sigaction action;
int option,ii;
char *buf;
+ int foreground = 0;
int ret = 0;
int ch;
@@ -402,7 +403,7 @@ int main (int argc, char ** argv)
}
// Analyse the command line
- while ((option = getopt(argc, argv, "c:f:n:hv")) != -1)
+ while ((option = getopt(argc, argv, "c:f:n:hvD")) != -1)
{
switch (option)
{
@@ -424,6 +425,10 @@ int main (int argc, char ** argv)
}
break;
+ case 'D': // Do not daemonize; run in foreground
+ foreground = 1;
+ break;
+
case 'h': // Print help
cmmHelp();
return 0;
@@ -443,9 +448,11 @@ int main (int argc, char ** argv)
goto err0;
}
- // Daemonize the application
- if(daemon(0, 1) == -1)
- goto err0;
+ // Daemonize the application unless foreground mode was requested
+ if (!foreground) {
+ if(daemon(0, 1) == -1)
+ goto err0;
+ }
//Ensure clean termination
action.sa_handler = sig_term_hdlr;
sigemptyset(&action.sa_mask);
@@ -471,9 +478,12 @@ int main (int argc, char ** argv)
//schedParams.sched_priority = 99;
//sched_setscheduler(0, SCHED_FIFO, &schedParams);
- //Init process does not set stdout on console
- if(freopen("/dev/console", "w", stdout) == NULL)
- goto err0;
+ // Init process does not set stdout on console.
+ // In foreground mode, keep stdout attached to the caller/container.
+ if (!foreground) {
+ if(freopen("/dev/console", "w", stdout) == NULL)
+ goto err0;
+ }
sigemptyset(&block_mask);
sigaddset(&block_mask, SIGTERM);
sigaddset(&block_mask, SIGPIPE);
--
2.47.3

View File

@@ -0,0 +1,36 @@
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