summaryrefslogtreecommitdiff
path: root/release/src/router/busybox/pgrep.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-01-03 12:04:58 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2015-01-03 12:04:58 +0100
commit008d0be72b2f160382c6e880765e96b64a050c65 (patch)
tree36f48a98a3815a408e2ce1693dd182af90f80305 /release/src/router/busybox/pgrep.c
parent611becfb8726c60cb060368541ad98191d4532f5 (diff)
downloadtomato-008d0be72b2f160382c6e880765e96b64a050c65.tar.gz
tomato-008d0be72b2f160382c6e880765e96b64a050c65.tar.bz2
imported original firmware WRT54GL_v4.30.11_11_US
Diffstat (limited to 'release/src/router/busybox/pgrep.c')
-rw-r--r--release/src/router/busybox/pgrep.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/release/src/router/busybox/pgrep.c b/release/src/router/busybox/pgrep.c
new file mode 100644
index 00000000..c3ed21a0
--- /dev/null
+++ b/release/src/router/busybox/pgrep.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <string.h> /* for strerror() */
+#include <errno.h>
+#include "busybox.h"
+
+
+extern int optind; /* in unistd.h */
+extern int errno; /* for use with strerror() */
+static char *opt_pattern = NULL;
+
+extern int pgrep_main(int argc, char **argv)
+{
+ int opt;
+ pid_t* pidList;
+
+ /* do normal option parsing */
+ while ((opt = getopt(argc, argv, "f")) > 0) {
+ switch (opt) {
+ case 'f':
+ break;
+ default:
+ show_usage();
+ }
+ }
+
+ if (argc - optind == 1)
+ opt_pattern = argv[optind];
+
+ if (!opt_pattern)
+ show_usage();
+
+ pidList = find_pid_by_name(opt_pattern);
+
+ if (!pidList || *pidList<=0) {
+ return EXIT_SUCCESS;
+ }
+
+ for(; pidList && *pidList!=0; pidList++) {
+ printf("%d\n", *pidList);
+ }
+
+ return EXIT_SUCCESS;
+}