|
|
@@ -31,14 +31,14 @@ struct os_process_pipe {
|
|
|
FILE *err_file;
|
|
|
};
|
|
|
|
|
|
-os_process_pipe_t *os_process_pipe_create(const char *cmd_line,
|
|
|
- const char *type)
|
|
|
+os_process_pipe_t *os_process_pipe_create_internal(const char *bin, char **argv,
|
|
|
+ const char *type)
|
|
|
{
|
|
|
struct os_process_pipe process_pipe = {0};
|
|
|
struct os_process_pipe *out;
|
|
|
posix_spawn_file_actions_t file_actions;
|
|
|
|
|
|
- if (!cmd_line || !type) {
|
|
|
+ if (!bin || !argv || !type) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
@@ -94,9 +94,8 @@ os_process_pipe_t *os_process_pipe_create(const char *cmd_line,
|
|
|
STDERR_FILENO);
|
|
|
|
|
|
int pid;
|
|
|
- char *argv[4] = {"sh", "-c", (char *)cmd_line, NULL};
|
|
|
-
|
|
|
- int ret = posix_spawn(&pid, "/bin/sh", &file_actions, NULL, argv, NULL);
|
|
|
+ int ret = posix_spawn(&pid, bin, &file_actions, NULL,
|
|
|
+ (char *const *)argv, NULL);
|
|
|
|
|
|
posix_spawn_file_actions_destroy(&file_actions);
|
|
|
|
|
|
@@ -127,6 +126,23 @@ os_process_pipe_t *os_process_pipe_create(const char *cmd_line,
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
+os_process_pipe_t *os_process_pipe_create(const char *cmd_line,
|
|
|
+ const char *type)
|
|
|
+{
|
|
|
+ if (!cmd_line)
|
|
|
+ return NULL;
|
|
|
+
|
|
|
+ char *argv[3] = {"-c", (char *)cmd_line, NULL};
|
|
|
+ return os_process_pipe_create_internal("/bin/sh", argv, type);
|
|
|
+}
|
|
|
+
|
|
|
+os_process_pipe_t *os_process_pipe_create2(const os_process_args_t *args,
|
|
|
+ const char *type)
|
|
|
+{
|
|
|
+ char **argv = os_process_args_get_argv(args);
|
|
|
+ return os_process_pipe_create_internal(argv[0], argv, type);
|
|
|
+}
|
|
|
+
|
|
|
int os_process_pipe_destroy(os_process_pipe_t *pp)
|
|
|
{
|
|
|
int ret = 0;
|