diff options
author | Drew DeVault <ddevault@linode.com> | 2016-04-29 10:59:43 -0400 |
---|---|---|
committer | Drew DeVault <ddevault@linode.com> | 2016-04-29 10:59:43 -0400 |
commit | ebdce719b4497302d373c065dd88f1071e907b5f (patch) | |
tree | f5cfaccfc2905946c6174fca539bf2b4fbd9cbc2 /sway/commands.c | |
parent | 3fa8df7b058eccce4f40e4966f07e8a02171cea0 (diff) |
Fix -Wunused-result problems
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sway/commands.c b/sway/commands.c index c1390016..3092239c 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -509,7 +509,9 @@ static struct cmd_results *cmd_exec_always(int argc, char **argv) { sway_log(L_DEBUG, "Executing %s", cmd); int fd[2]; - pipe(fd); + if (pipe(fd) != 0) { + sway_log(L_ERROR, "Unable to create pipe for fork"); + } pid_t pid; pid_t *child = malloc(sizeof(pid_t)); // malloc'd so that Linux can avoid copying the process space @@ -522,14 +524,20 @@ static struct cmd_results *cmd_exec_always(int argc, char **argv) { /* Not reached */ } close(fd[0]); - write(fd[1], child, sizeof(pid_t)); + ssize_t s = 0; + while ((size_t)s < sizeof(pid_t)) { + s += write(fd[1], ((uint8_t *)child) + s, sizeof(pid_t)); + } close(fd[1]); _exit(0); // Close child process } else if (pid < 0) { return cmd_results_new(CMD_FAILURE, "exec_always", "Command failed (sway could not fork)."); } close(fd[1]); // close write - read(fd[0], child, sizeof(pid_t)); + ssize_t s = 0; + while ((size_t)s < sizeof(pid_t)) { + s += read(fd[0], ((uint8_t *)child) + s, sizeof(pid_t)); + } close(fd[0]); // cleanup child process wait(0); |