1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
From df011a889e907da49083d6dcbcc42c718e3c84b3 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Tue, 8 Aug 2023 03:45:28 +0200
Subject: [PATCH 5/5] inetd: Add new --foreground option
This option avoids daemonizing, like --debug, except that it does not
imply debugging output. To be used primary by the systemd service.
Origin: vendor, Debian
Forwarded: no
diff --git a/src/inetd.c b/src/inetd.c
index e0da376d..8252d3b9 100644
--- a/src/inetd.c
+++ b/src/inetd.c
@@ -150,6 +150,7 @@
#define SIGBLOCK (sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM))
bool debug = false;
+bool foreground = false;
int nsock, maxsock;
fd_set allsock;
int options;
@@ -172,6 +173,7 @@ const char doc[] = "Internet super-server.";
enum
{
OPT_ENVIRON = 256,
+ OPT_FOREGROUND,
OPT_RESOLVE
};
@@ -184,6 +186,8 @@ const char *program_authors[] = {
static struct argp_option argp_options[] = {
#define GRP 0
+ {"foreground", OPT_FOREGROUND, NULL, 0,
+ "run in foreground mode", GRP+1},
{"debug", 'd', NULL, 0,
"turn on debugging, run in foreground mode", GRP + 1},
{"environment", OPT_ENVIRON, NULL, 0,
@@ -211,9 +215,14 @@ parse_opt (int key, char *arg, struct argp_state *state MAYBE_UNUSED)
{
case 'd':
debug = true;
+ foreground = true;
options |= SO_DEBUG;
break;
+ case OPT_FOREGROUND:
+ foreground = true;
+ break;
+
case OPT_ENVIRON:
env_option = true;
break;
@@ -1955,7 +1964,7 @@ main (int argc, char *argv[], char *envp[])
config_files[1] = newstr (PATH_INETDDIR);
}
- if (!debug)
+ if (!foreground)
{
if (daemon (0, 0) < 0)
{
--
2.47.2
|