aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/process.c
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-08-26 07:15:03 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-08-26 07:15:45 +0200
commit93b8646855353ab3adfe5fea8ccb5b0842ad8a0d (patch)
treec87ac95cd819f654d60e360f84a5559faa7de9fe /src/process.c
parentfix macros (diff)
downloadcimple-93b8646855353ab3adfe5fea8ccb5b0842ad8a0d.tar.gz
cimple-93b8646855353ab3adfe5fea8ccb5b0842ad8a0d.zip
add check_errno macro
Diffstat (limited to '')
-rw-r--r--src/process.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/process.c b/src/process.c
index 7d62a88..c4ff307 100644
--- a/src/process.c
+++ b/src/process.c
@@ -54,7 +54,7 @@ static int redirect_and_exec_child(int pipe_fds[2], const char *args[])
{
int ret = 0;
- close(pipe_fds[0]);
+ check_errno(close(pipe_fds[0]), "close");
ret = dup2(pipe_fds[1], STDOUT_FILENO);
if (ret < 0) {
@@ -91,7 +91,7 @@ int proc_capture(const char *args[], struct proc_output *result)
if (!child_pid)
exit(redirect_and_exec_child(pipe_fds, args));
- close(pipe_fds[1]);
+ check_errno(close(pipe_fds[1]), "close");
ret = file_read(pipe_fds[0], &result->output, &result->output_len);
if (ret < 0)
@@ -107,7 +107,8 @@ free_output:
free(result->output);
close_pipe:
- close(pipe_fds[0]);
+ check_errno(close(pipe_fds[0]), "close");
+ /* No errno checking here, we might've already closed the write end. */
close(pipe_fds[1]);
return ret;