summaryrefslogtreecommitdiff
path: root/os-posix.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-02 13:36:38 -0500
committerpommicket <pommicket@gmail.com>2023-01-02 13:36:38 -0500
commitc0d0117a963cf8e4dfb28b919087d8a8ecbbca6e (patch)
tree0c412921f82f141cf733e8de4b4b02152446dba5 /os-posix.c
parent1dc24e79ec7cf80e06b9c4e7cc55e18857b624c1 (diff)
fix up restructuring
Diffstat (limited to 'os-posix.c')
-rw-r--r--os-posix.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/os-posix.c b/os-posix.c
index 4e9e402..5b37268 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -153,19 +153,19 @@ static void set_nonblocking(int fd) {
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
}
-bool process_run_ex(Process *proc, const char *command, const ProcessSettings *settings) {
- memset(proc, 0, sizeof *proc);
+Process *process_run_ex(const char *command, const ProcessSettings *settings) {
+ Process *proc = calloc(1, sizeof *proc);
int stdin_pipe[2] = {0}, stdout_pipe[2] = {0}, stderr_pipe[2] = {0};
if (pipe(stdin_pipe) != 0) {
strbuf_printf(proc->error, "%s", strerror(errno));
- return false;
+ return proc;
}
if (pipe(stdout_pipe) != 0) {
strbuf_printf(proc->error, "%s", strerror(errno));
close(stdin_pipe[0]);
close(stdin_pipe[1]);
- return false;
+ return proc;
}
if (settings->separate_stderr) {
if (pipe(stderr_pipe) != 0) {
@@ -174,7 +174,7 @@ bool process_run_ex(Process *proc, const char *command, const ProcessSettings *s
close(stdin_pipe[1]);
close(stdout_pipe[0]);
close(stdout_pipe[1]);
- return false;
+ return proc;
}
}
@@ -232,14 +232,13 @@ bool process_run_ex(Process *proc, const char *command, const ProcessSettings *s
if (stderr_pipe[0])
proc->stderr_pipe = stderr_pipe[0];
proc->stdin_pipe = stdin_pipe[1];
- success = true;
}
- return success;
+ return proc;
}
-bool process_run(Process *proc, const char *command) {
+Process *process_run(const char *command) {
const ProcessSettings settings = {0};
- return process_run_ex(proc, command, &settings);
+ return process_run_ex(command, &settings);
}