aboutsummaryrefslogtreecommitdiff
path: root/lib/pending.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-12-19 09:32:30 -0600
committerRob Landley <rob@landley.net>2013-12-19 09:32:30 -0600
commitdb1009dc5c7606e5abf01d41f82ca18001dc1f52 (patch)
treedbfe1017ca240a1dfad4337a0cc40e53626d71f9 /lib/pending.c
parentc4a8ce4fe303ff66f1cf2fd3d14aef303d25287e (diff)
downloadtoybox-db1009dc5c7606e5abf01d41f82ca18001dc1f52.tar.gz
Move names_to_pid from pending to lib.
Diffstat (limited to 'lib/pending.c')
-rw-r--r--lib/pending.c25
1 files changed, 0 insertions, 25 deletions
diff --git a/lib/pending.c b/lib/pending.c
index df3207ef..741c5cc1 100644
--- a/lib/pending.c
+++ b/lib/pending.c
@@ -5,31 +5,6 @@
#include "toys.h"
-// Execute a callback for each PID that matches a process name from a list.
-void names_to_pid(char **names, int (*callback)(pid_t pid, char *name))
-{
- DIR *dp;
- struct dirent *entry;
-
- if (!(dp = opendir("/proc"))) perror_exit("opendir");
-
- while ((entry = readdir(dp))) {
- unsigned u;
- char *cmd, **curname;
-
- if (!(u = atoi(entry->d_name))) continue;
- sprintf(libbuf, "/proc/%u/cmdline", u);
- 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) break;
- }
- closedir(dp);
-}
-
void daemonize(void)
{
int fd = open("/dev/null", O_RDWR);