diff lib/pending.c @ 1068:7ada6da9540a draft 0.4.6

Ah, that's why commit 1057 was skipped last pull: it was unfinished. Oops. (Fix it.)
author Rob Landley <rob@landley.net>
date Wed, 11 Sep 2013 12:09:53 -0500
parents 4263a4390758
children b2a8f64a564b
line wrap: on
line diff
--- a/lib/pending.c	Tue Sep 10 02:04:45 2013 -0500
+++ b/lib/pending.c	Wed Sep 11 12:09:53 2013 -0500
@@ -6,7 +6,7 @@
 #include "toys.h"
 
 // Execute a callback for each PID that matches a process name from a list.
-void name_to_pid(char **names, int (*callback)(pid_t pid, char *name))
+void names_to_pid(char **names, int (*callback)(pid_t pid, char *name))
 {
   DIR *dp;
   struct dirent *entry;
@@ -14,7 +14,6 @@
   if (!(dp = opendir("/proc"))) perror_exit("opendir");
 
   while ((entry = readdir(dp))) {
-    int fd, n;
     unsigned u;
     char *cmd, **curname;
 
@@ -23,9 +22,9 @@
     if (!(cmd = readfile(libbuf, libbuf, sizeof(libbuf)))) continue;
 
     for (curname = names; *curname; curname++)
-      if (*curname == '/' ? !strcmp(cmd, *curname)
-          : !strcmp(basename(cmd), basename(*curname))
-        if (!callback(u, *curname)) break;
+      if (**curname == '/' ? !strcmp(cmd, *curname)
+          : !strcmp(basename(cmd), basename(*curname)))
+        if (callback(u, *curname)) break;
     if (*curname) break;
   }
   closedir(dp);