diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-12-05 07:24:08 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-12-05 07:24:08 +0000 |
commit | deca106b6dad70ad0a1312a82d762aa8d8ad52ba (patch) | |
tree | f11db23c430298ac9da2f3de80ec6c86cc75be70 /libbb/find_pid_by_name.c | |
parent | 6f9b45b9eff22c664b93ace82d20669340a762f8 (diff) | |
download | busybox-w32-deca106b6dad70ad0a1312a82d762aa8d8ad52ba.tar.gz busybox-w32-deca106b6dad70ad0a1312a82d762aa8d8ad52ba.tar.bz2 busybox-w32-deca106b6dad70ad0a1312a82d762aa8d8ad52ba.zip |
Kill CONFIG_FEATURE_USE_DEVPS_PATCH and the devps patch. I'm not
maintaining it anymore, and it is now terribly out of date.
-Erik
Diffstat (limited to 'libbb/find_pid_by_name.c')
-rw-r--r-- | libbb/find_pid_by_name.c | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c index a648137e1..b9c06d724 100644 --- a/libbb/find_pid_by_name.c +++ b/libbb/find_pid_by_name.c | |||
@@ -27,88 +27,6 @@ | |||
27 | 27 | ||
28 | #define READ_BUF_SIZE 50 | 28 | #define READ_BUF_SIZE 50 |
29 | 29 | ||
30 | |||
31 | /* For Erik's nifty devps device driver */ | ||
32 | #ifdef CONFIG_FEATURE_USE_DEVPS_PATCH | ||
33 | #include <linux/devps.h> | ||
34 | |||
35 | /* find_pid_by_name() | ||
36 | * | ||
37 | * This finds the pid of the specified process, | ||
38 | * by using the /dev/ps device driver. | ||
39 | * | ||
40 | * Returns a list of all matching PIDs | ||
41 | */ | ||
42 | extern long* find_pid_by_name( const char* pidName) | ||
43 | { | ||
44 | int fd, i, j; | ||
45 | char device[] = "/dev/ps"; | ||
46 | pid_t num_pids; | ||
47 | pid_t* pid_array = NULL; | ||
48 | long* pidList=NULL; | ||
49 | |||
50 | /* open device */ | ||
51 | fd = open(device, O_RDONLY); | ||
52 | if (fd < 0) | ||
53 | perror_msg_and_die("open failed for `%s'", device); | ||
54 | |||
55 | /* Find out how many processes there are */ | ||
56 | if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) | ||
57 | perror_msg_and_die("\nDEVPS_GET_PID_LIST"); | ||
58 | |||
59 | /* Allocate some memory -- grab a few extras just in case | ||
60 | * some new processes start up while we wait. The kernel will | ||
61 | * just ignore any extras if we give it too many, and will trunc. | ||
62 | * the list if we give it too few. */ | ||
63 | pid_array = (pid_t*) xcalloc( num_pids+10, sizeof(pid_t)); | ||
64 | pid_array[0] = num_pids+10; | ||
65 | |||
66 | /* Now grab the pid list */ | ||
67 | if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) | ||
68 | perror_msg_and_die("\nDEVPS_GET_PID_LIST"); | ||
69 | |||
70 | /* Now search for a match */ | ||
71 | for (i=1, j=0; i<pid_array[0] ; i++) { | ||
72 | char* p; | ||
73 | struct pid_info info; | ||
74 | |||
75 | info.pid = pid_array[i]; | ||
76 | if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) | ||
77 | perror_msg_and_die("\nDEVPS_GET_PID_INFO"); | ||
78 | |||
79 | /* Make sure we only match on the process name */ | ||
80 | p=info.command_line+1; | ||
81 | while ((*p != 0) && !isspace(*(p)) && (*(p-1) != '\\')) { | ||
82 | (p)++; | ||
83 | } | ||
84 | if (isspace(*(p))) | ||
85 | *p='\0'; | ||
86 | |||
87 | if ((strstr(info.command_line, pidName) != NULL) | ||
88 | && (strlen(pidName) == strlen(info.command_line))) { | ||
89 | pidList=xrealloc( pidList, sizeof(long) * (j+2)); | ||
90 | pidList[j++]=info.pid; | ||
91 | } | ||
92 | } | ||
93 | if (pidList) { | ||
94 | pidList[j]=0; | ||
95 | } else { | ||
96 | pidList=xrealloc( pidList, sizeof(long)); | ||
97 | pidList[0]=-1; | ||
98 | } | ||
99 | |||
100 | /* Free memory */ | ||
101 | free( pid_array); | ||
102 | |||
103 | /* close device */ | ||
104 | if (close (fd) != 0) | ||
105 | perror_msg_and_die("close failed for `%s'", device); | ||
106 | |||
107 | return pidList; | ||
108 | } | ||
109 | |||
110 | #else /* CONFIG_FEATURE_USE_DEVPS_PATCH */ | ||
111 | |||
112 | /* find_pid_by_name() | 30 | /* find_pid_by_name() |
113 | * | 31 | * |
114 | * Modified by Vladimir Oleynik for use with libbb/procps.c | 32 | * Modified by Vladimir Oleynik for use with libbb/procps.c |
@@ -135,7 +53,6 @@ extern long* find_pid_by_name( const char* pidName) | |||
135 | pidList[i] = i==0 ? -1 : 0; | 53 | pidList[i] = i==0 ? -1 : 0; |
136 | return pidList; | 54 | return pidList; |
137 | } | 55 | } |
138 | #endif /* CONFIG_FEATURE_USE_DEVPS_PATCH */ | ||
139 | 56 | ||
140 | /* END CODE */ | 57 | /* END CODE */ |
141 | /* | 58 | /* |