summaryrefslogtreecommitdiffstats
path: root/libnetdata/popen/popen.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-09 04:52:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-09 04:52:39 +0000
commit89f3604407aff8f4cb2ed958252c61e23c767e24 (patch)
tree7fbf408102cab051557d38193524d8c6e991d070 /libnetdata/popen/popen.h
parentAdding upstream version 1.34.1. (diff)
downloadnetdata-b2632fc3ce7e8fdc5703ea02a4780885d89438c5.tar.xz
netdata-b2632fc3ce7e8fdc5703ea02a4780885d89438c5.zip
Adding upstream version 1.35.0.upstream/1.35.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/popen/popen.h')
-rw-r--r--libnetdata/popen/popen.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/libnetdata/popen/popen.h b/libnetdata/popen/popen.h
index f387cff0a..57eb9131e 100644
--- a/libnetdata/popen/popen.h
+++ b/libnetdata/popen/popen.h
@@ -8,6 +8,23 @@
#define PIPE_READ 0
#define PIPE_WRITE 1
+/* custom_popene_variadic_internal_dont_use_directly flag definitions */
+#define POPEN_FLAG_NONE 0
+#define POPEN_FLAG_CREATE_PIPE 1 // Create a pipe like popen() when set, otherwise set stdout to /dev/null
+#define POPEN_FLAG_CLOSE_FD 2 // Close all file descriptors other than STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO
+
+// the flags to be used by default
+#define POPEN_FLAGS_DEFAULT (POPEN_FLAG_CREATE_PIPE|POPEN_FLAG_CLOSE_FD)
+
+// mypopen_raw is the interface to use instead of custom_popene_variadic_internal_dont_use_directly()
+// mypopen_raw will add the terminating NULL at the arguments list
+// we append the parameter 'command' twice - this is because the underlying call needs the command to execute and the argv[0] to pass to it
+#define mypopen_raw_default_flags_and_environment(pidptr, fpp, command, args...) custom_popene_variadic_internal_dont_use_directly(pidptr, environ, POPEN_FLAGS_DEFAULT, fpp, command, command, ##args, NULL)
+#define mypopen_raw_default_flags(pidptr, env, fpp, command, args...) custom_popene_variadic_internal_dont_use_directly(pidptr, env, POPEN_FLAGS_DEFAULT, fpp, command, command, ##args, NULL)
+#define mypopen_raw(pidptr, env, flags, fpp, command, args...) custom_popene_variadic_internal_dont_use_directly(pidptr, env, flags, fpp, command, command, ##args, NULL)
+
+extern int custom_popene_variadic_internal_dont_use_directly(volatile pid_t *pidptr, char **env, uint8_t flags, FILE **fpp, const char *command, ...);
+
extern FILE *mypopen(const char *command, volatile pid_t *pidptr);
extern FILE *mypopene(const char *command, volatile pid_t *pidptr, char **env);
extern int mypclose(FILE *fp, pid_t pid);