diff options
author | Robert Griebl <griebl@gmx.de> | 2002-05-22 23:38:12 +0000 |
---|---|---|
committer | Robert Griebl <griebl@gmx.de> | 2002-05-22 23:38:12 +0000 |
commit | d11edf98094533af3e322c5f42e756e2e786ba0c (patch) | |
tree | 46fabd1c8ef05a4943c6c0e34c567144b42e874a | |
parent | 236abbfd713dcce35066322e6ac3ef53b074f429 (diff) | |
download | busybox-w32-d11edf98094533af3e322c5f42e756e2e786ba0c.tar.gz busybox-w32-d11edf98094533af3e322c5f42e756e2e786ba0c.tar.bz2 busybox-w32-d11edf98094533af3e322c5f42e756e2e786ba0c.zip |
Made exit code SysV compliant. Also added -s (single pid) flag.
-rw-r--r-- | procps/pidof.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/procps/pidof.c b/procps/pidof.c index c75571a01..d0d65e0db 100644 --- a/procps/pidof.c +++ b/procps/pidof.c | |||
@@ -36,26 +36,20 @@ | |||
36 | extern int pidof_main(int argc, char **argv) | 36 | extern int pidof_main(int argc, char **argv) |
37 | { | 37 | { |
38 | int opt, n = 0; | 38 | int opt, n = 0; |
39 | 39 | int single_flag = 0; | |
40 | int fail = 1; | ||
40 | 41 | ||
41 | /* do normal option parsing */ | 42 | /* do normal option parsing */ |
42 | while ((opt = getopt(argc, argv, "ne:f:")) > 0) { | 43 | while ((opt = getopt(argc, argv, "s")) > 0) { |
43 | switch (opt) { | 44 | switch (opt) { |
44 | #if 0 | 45 | case 's': |
45 | case 'g': | 46 | single_flag = 1; |
46 | break; | ||
47 | case 'e': | ||
48 | break; | 47 | break; |
49 | #endif | ||
50 | default: | 48 | default: |
51 | show_usage(); | 49 | show_usage(); |
52 | } | 50 | } |
53 | } | 51 | } |
54 | 52 | ||
55 | /* if we didn't get a process name, then we need to choke and die here */ | ||
56 | if (argv[optind] == NULL) | ||
57 | show_usage(); | ||
58 | |||
59 | /* Looks like everything is set to go. */ | 53 | /* Looks like everything is set to go. */ |
60 | while(optind < argc) { | 54 | while(optind < argc) { |
61 | long* pidList; | 55 | long* pidList; |
@@ -67,6 +61,9 @@ extern int pidof_main(int argc, char **argv) | |||
67 | 61 | ||
68 | for(; pidList && *pidList!=0; pidList++) { | 62 | for(; pidList && *pidList!=0; pidList++) { |
69 | printf("%s%ld", (n++ ? " " : ""), (long)*pidList); | 63 | printf("%s%ld", (n++ ? " " : ""), (long)*pidList); |
64 | fail = 0; | ||
65 | if (single_flag) | ||
66 | break; | ||
70 | } | 67 | } |
71 | /* Note that we don't bother to free the memory | 68 | /* Note that we don't bother to free the memory |
72 | * allocated in find_pid_by_name(). It will be freed | 69 | * allocated in find_pid_by_name(). It will be freed |
@@ -75,5 +72,5 @@ extern int pidof_main(int argc, char **argv) | |||
75 | } | 72 | } |
76 | printf("\n"); | 73 | printf("\n"); |
77 | 74 | ||
78 | return EXIT_SUCCESS; | 75 | return fail ? EXIT_FAILURE : EXIT_SUCCESS; |
79 | } | 76 | } |