diff options
author | Elie De Brauwer <eliedebrauwer@gmail.com> | 2012-12-08 20:10:05 +0100 |
---|---|---|
committer | Elie De Brauwer <eliedebrauwer@gmail.com> | 2012-12-08 20:10:05 +0100 |
commit | 7c6209d6c336df74984e62aa88679c06641ae309 (patch) | |
tree | b4bcc499ecfc4fe43ec6685803020f42c332e9c9 /lib/lib.c | |
parent | d394a1fb216b3a4653848f6625f8f731d7d34ac7 (diff) | |
download | toybox-7c6209d6c336df74984e62aa88679c06641ae309.tar.gz |
Adding -s (single shot) and -o (omit pids) options to pidof
Diffstat (limited to 'lib/lib.c')
-rw-r--r-- | lib/lib.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -975,7 +975,7 @@ int yesno(char *prompt, int def) } // Execute a callback for each PID that matches a process name from a list. -void for_each_pid_with_name_in(char **names, void (*callback)(pid_t pid)) +void for_each_pid_with_name_in(char **names, int (*callback)(pid_t pid)) { DIR *dp; struct dirent *entry; @@ -998,9 +998,10 @@ void for_each_pid_with_name_in(char **names, void (*callback)(pid_t pid)) if (n<1) continue; for (curname = names; *curname; curname++) - if (!strcmp(basename(cmd), *curname)) callback(atol(entry->d_name)); + if (!strcmp(basename(cmd), *curname)) + if (!callback(atol(entry->d_name))) goto done; } - +done: closedir(dp); } |