summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x.bin/pbd.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/.bin/pbd.c b/.bin/pbd.c
index 47fdedc4..9e716d6d 100755
--- a/.bin/pbd.c
+++ b/.bin/pbd.c
@@ -8,6 +8,7 @@ exec clang -Weverything $@ -o $(dirname $0)/pbd $0
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/socket.h>
+#include <sys/wait.h>
 #include <sysexits.h>
 #include <unistd.h>
 
@@ -17,19 +18,23 @@ static void spawn(const char *cmd, int child_fd, int parent_fd) {
 
     if (pid) {
         int status;
-        if (waitpid(pid, &status, 0) < 0)
-            err(EX_OSERR, "waitpid");
+        pid_t wait = waitpid(pid, &status, 0);
+        if (wait < 0) err(EX_OSERR, "waitpid");
+
         if (status)
             warnx("child %s status %d", cmd, status);
     } else {
-        if (dup2(parent_fd, child_fd) < 0)
-            err(EX_OSERR, "dup2");
-        if (execlp(cmd, cmd) < 0)
-            err(EX_OSERR, "execlp");
+        int fd = dup2(parent_fd, child_fd);
+        if (fd < 0) err(EX_OSERR, "dup2");
+
+        int error = execlp(cmd, cmd);
+        if (error) err(EX_OSERR, "execlp");
     }
 }
 
 int main() {
+    int error;
+
     int server = socket(PF_INET, SOCK_STREAM, 0);
     if (server < 0) err(EX_OSERR, "socket");
 
@@ -39,11 +44,11 @@ int main() {
         .sin_addr = { .s_addr = htonl(0x7f000001) },
     };
 
-    if (bind(server, (struct sockaddr *) &addr, sizeof(addr)) < 0)
-        err(EX_OSERR, "bind");
+    error = bind(server, (struct sockaddr *) &addr, sizeof(addr));
+    if (error) err(EX_OSERR, "bind");
 
-    if (listen(server, 1) < 0)
-        err(EX_OSERR, "listen");
+    error = listen(server, 1);
+    if (error) err(EX_OSERR, "listen");
 
     for (;;) {
         int client = accept(server, NULL, NULL);
@@ -57,7 +62,7 @@ int main() {
 
         if (peek) spawn("pbcopy", STDIN_FILENO, client);
 
-        if (close(client) < 0)
-            err(EX_IOERR, "close");
+        error = close(client);
+        if (error) err(EX_IOERR, "close");
     }
 }
021-09-22Support HTTP PUT in upJune McEnroe 2021-09-22Remove default faviconJune McEnroe 2021-09-21Use Z_FILTERED strategyJune McEnroe 2021-09-21Recalculate various lengths only as neededJune McEnroe 2021-09-21Rewrite pngo, add explicit optionsJune McEnroe 2021-09-16Fix /* **/ comment matchingJune McEnroe 2021-09-15Remove typer, add downgrade to READMEJune McEnroe 2021-09-15Set bot mode on downgradeJune McEnroe 2021-09-15Enter capsicum in downgradeJune McEnroe 2021-09-15Factor out common parts of downgrade messagesJune McEnroe 2021-09-14Add downgrade IRC botJune McEnroe 2021-09-14Sort by title if authors matchJune McEnroe 2021-09-13Swap-remove tags as they're foundJune McEnroe 2021-09-12Replace htagml regex with strncmpJune McEnroe 2021-09-11Also defer printing comment for lone close-parensJune McEnroe 2021-09-10Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe