plugin_services: scope the popen/procfs readers to POSIX so the Windows slice is warning-free
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-12 08:37:50
Commitda52ce31
Parentsb5557676
Changed files
src/plugin_services.c+4−4■■■■■
1 file+4−4
Diff
src/plugin_services.c+4−4■■■■■
index 98f0f33..6902b96 100644
--- a/src/plugin_services.c
+++ b/src/plugin_services.c
@@ -314,6 +314,7 @@ static void require_node_auth(void)
314314 /* Command capture and argv execution */
315315 /* ------------------------------------------------------------------ */
316316
317+#if !defined(_WIN32)
317318 /* Every command string passed here is a CONSTANT defined in this file, or is
318319 * built from a value that already passed valid_unit(). Nothing user-supplied
319320 * reaches this function unvalidated. */
@@ -334,7 +335,6 @@ static int capture(const char *cmd, char *out, size_t outsz)
334335 return (int)n;
335336 }
336337
337-#if !defined(_WIN32)
338338 /* Returns the child's exit status, or -1 when it could not be started. The
339339 * unit is a separate argv element, so no shell ever sees it. */
340340 static int run_argv(char *const argv[])
@@ -357,6 +357,8 @@ static int run_argv(char *const argv[])
357357 /* ------------------------------------------------------------------ */
358358 /* Minimal JSON field extraction (for systemctl --output=json output) */
359359 /* ------------------------------------------------------------------ */
360+/* The JSON readers and the systemd/launchd parsers are POSIX-only: the
361+ * Windows slice talks to the SCM directly and never parses text. */
360362
361363 static int json_read_string_at(const char **pp, char *out, size_t outsz)
362364 {
@@ -476,6 +478,7 @@ static svc_t *svc_find(const char *name)
476478 return NULL;
477479 }
478480
481+#if !defined(_WIN32)
479482 static char *read_file_all(const char *path, size_t *len)
480483 {
481484 FILE *f;
@@ -670,7 +673,6 @@ static void apply_show(const char *text)
670673 }
671674
672675 /* Containers with no init system: list /proc/<pid> long-running daemons. */
673-#if !defined(_WIN32)
674676 static int collect_proc_daemons(void)
675677 {
676678 const char *root = getenv("SERVICES_MOCK_PROC_DIR");
@@ -761,9 +763,7 @@ static int collect_proc_daemons(void)
761763 closedir(d);
762764 return g_count;
763765 }
764-#endif /* !_WIN32 */
765766
766-#if !defined(_WIN32)
767767 static void collect_systemd(void)
768768 {
769769 const char *mock = getenv("SERVICES_MOCK_SYSTEMCTL");
770770
src/plugin_services.c+4−4■■■■■
index 98f0f33..6902b96 100644index 98f0f33..6902b96 100644
--- a/src/plugin_services.c--- a/src/plugin_services.c
+++ b/src/plugin_services.c+++ b/src/plugin_services.c
@@ -314,6 +314,7 @@ static void require_node_auth(void)@@ -314,6 +314,7 @@ static void require_node_auth(void)
314 /* Command capture and argv execution */314 /* Command capture and argv execution */
315 /* ------------------------------------------------------------------ */315 /* ------------------------------------------------------------------ */
316 316
317+#if !defined(_WIN32)
317 /* Every command string passed here is a CONSTANT defined in this file, or is318 /* Every command string passed here is a CONSTANT defined in this file, or is
318 * built from a value that already passed valid_unit(). Nothing user-supplied319 * built from a value that already passed valid_unit(). Nothing user-supplied
319 * reaches this function unvalidated. */320 * reaches this function unvalidated. */
@@ -334,7 +335,6 @@ static int capture(const char *cmd, char *out, size_t outsz)@@ -334,7 +335,6 @@ static int capture(const char *cmd, char *out, size_t outsz)
334 return (int)n;335 return (int)n;
335 }336 }
336 337
337-#if !defined(_WIN32)
338 /* Returns the child's exit status, or -1 when it could not be started. The338 /* Returns the child's exit status, or -1 when it could not be started. The
339 * unit is a separate argv element, so no shell ever sees it. */339 * unit is a separate argv element, so no shell ever sees it. */
340 static int run_argv(char *const argv[])340 static int run_argv(char *const argv[])
@@ -357,6 +357,8 @@ static int run_argv(char *const argv[])@@ -357,6 +357,8 @@ static int run_argv(char *const argv[])
357 /* ------------------------------------------------------------------ */357 /* ------------------------------------------------------------------ */
358 /* Minimal JSON field extraction (for systemctl --output=json output) */358 /* Minimal JSON field extraction (for systemctl --output=json output) */
359 /* ------------------------------------------------------------------ */359 /* ------------------------------------------------------------------ */
360+/* The JSON readers and the systemd/launchd parsers are POSIX-only: the
361+ * Windows slice talks to the SCM directly and never parses text. */
360 362
361 static int json_read_string_at(const char **pp, char *out, size_t outsz)363 static int json_read_string_at(const char **pp, char *out, size_t outsz)
362 {364 {
@@ -476,6 +478,7 @@ static svc_t *svc_find(const char *name)@@ -476,6 +478,7 @@ static svc_t *svc_find(const char *name)
476 return NULL;478 return NULL;
477 }479 }
478 480
481+#if !defined(_WIN32)
479 static char *read_file_all(const char *path, size_t *len)482 static char *read_file_all(const char *path, size_t *len)
480 {483 {
481 FILE *f;484 FILE *f;
@@ -670,7 +673,6 @@ static void apply_show(const char *text)@@ -670,7 +673,6 @@ static void apply_show(const char *text)
670 }673 }
671 674
672 /* Containers with no init system: list /proc/<pid> long-running daemons. */675 /* Containers with no init system: list /proc/<pid> long-running daemons. */
673-#if !defined(_WIN32)
674 static int collect_proc_daemons(void)676 static int collect_proc_daemons(void)
675 {677 {
676 const char *root = getenv("SERVICES_MOCK_PROC_DIR");678 const char *root = getenv("SERVICES_MOCK_PROC_DIR");
@@ -761,9 +763,7 @@ static int collect_proc_daemons(void)@@ -761,9 +763,7 @@ static int collect_proc_daemons(void)
761 closedir(d);763 closedir(d);
762 return g_count;764 return g_count;
763 }765 }
764-#endif /* !_WIN32 */
765 766
766-#if !defined(_WIN32)
767 static void collect_systemd(void)767 static void collect_systemd(void)
768 {768 {
769 const char *mock = getenv("SERVICES_MOCK_SYSTEMCTL");769 const char *mock = getenv("SERVICES_MOCK_SYSTEMCTL");
770770