diff options
Diffstat (limited to 'procps')
-rw-r--r-- | procps/free.c | 6 | ||||
-rw-r--r-- | procps/kill.c | 299 | ||||
-rw-r--r-- | procps/ps.c | 206 |
3 files changed, 260 insertions, 251 deletions
diff --git a/procps/free.c b/procps/free.c index 36d357522..b07135430 100644 --- a/procps/free.c +++ b/procps/free.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * Mini free implementation for busybox | 3 | * Mini free implementation for busybox |
3 | * | 4 | * |
@@ -30,6 +31,7 @@ | |||
30 | 31 | ||
31 | extern int free_main(int argc, char **argv) | 32 | extern int free_main(int argc, char **argv) |
32 | { | 33 | { |
33 | char* cmd[] = { "cat", "/proc/meminfo", "\0" }; | 34 | char *cmd[] = { "cat", "/proc/meminfo", "\0" }; |
34 | exit(cat_main( 3, cmd)); | 35 | |
36 | exit(cat_main(3, cmd)); | ||
35 | } | 37 | } |
diff --git a/procps/kill.c b/procps/kill.c index e72b73493..516621232 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * Mini kill implementation for busybox | 3 | * Mini kill implementation for busybox |
3 | * | 4 | * |
@@ -29,188 +30,188 @@ | |||
29 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
30 | #include <unistd.h> | 31 | #include <unistd.h> |
31 | 32 | ||
32 | static const char* kill_usage = "kill [-signal] process-id [process-id ...]\n\n" | 33 | static const char *kill_usage = |
33 | "Send a signal (default is SIGTERM) to the specified process(es).\n\n" | 34 | "kill [-signal] process-id [process-id ...]\n\n" |
34 | "Options:\n" | 35 | "Send a signal (default is SIGTERM) to the specified process(es).\n\n" |
35 | "\t-l\tList all signal names and numbers.\n\n"; | 36 | "Options:\n" "\t-l\tList all signal names and numbers.\n\n"; |
36 | 37 | ||
37 | 38 | ||
38 | struct signal_name { | 39 | struct signal_name { |
39 | const char *name; | 40 | const char *name; |
40 | int number; | 41 | int number; |
41 | }; | 42 | }; |
42 | 43 | ||
43 | const struct signal_name signames[] = { | 44 | const struct signal_name signames[] = { |
44 | {"HUP", SIGHUP}, | 45 | {"HUP", SIGHUP}, |
45 | {"INT", SIGINT}, | 46 | {"INT", SIGINT}, |
46 | {"QUIT", SIGQUIT}, | 47 | {"QUIT", SIGQUIT}, |
47 | {"ILL", SIGILL}, | 48 | {"ILL", SIGILL}, |
48 | {"TRAP", SIGTRAP}, | 49 | {"TRAP", SIGTRAP}, |
49 | {"ABRT", SIGABRT}, | 50 | {"ABRT", SIGABRT}, |
50 | #ifndef __alpha__ | 51 | #ifndef __alpha__ |
51 | {"IOT", SIGIOT}, | 52 | {"IOT", SIGIOT}, |
52 | #endif | 53 | #endif |
53 | #if defined(__sparc__) || defined(__alpha__) | 54 | #if defined(__sparc__) || defined(__alpha__) |
54 | {"EMT", SIGEMT}, | 55 | {"EMT", SIGEMT}, |
55 | #else | 56 | #else |
56 | {"BUS", SIGBUS}, | 57 | {"BUS", SIGBUS}, |
57 | #endif | 58 | #endif |
58 | {"FPE", SIGFPE}, | 59 | {"FPE", SIGFPE}, |
59 | {"KILL", SIGKILL}, | 60 | {"KILL", SIGKILL}, |
60 | #if defined(__sparc__) || defined(__alpha__) | 61 | #if defined(__sparc__) || defined(__alpha__) |
61 | {"BUS", SIGBUS}, | 62 | {"BUS", SIGBUS}, |
62 | #else | 63 | #else |
63 | {"USR1", SIGUSR1}, | 64 | {"USR1", SIGUSR1}, |
64 | #endif | 65 | #endif |
65 | {"SEGV", SIGSEGV}, | 66 | {"SEGV", SIGSEGV}, |
66 | #if defined(__sparc__) || defined(__alpha__) | 67 | #if defined(__sparc__) || defined(__alpha__) |
67 | {"SYS", SIGSYS}, | 68 | {"SYS", SIGSYS}, |
68 | #else | 69 | #else |
69 | {"USR2", SIGUSR2}, | 70 | {"USR2", SIGUSR2}, |
70 | #endif | 71 | #endif |
71 | {"PIPE", SIGPIPE}, | 72 | {"PIPE", SIGPIPE}, |
72 | {"ALRM", SIGALRM}, | 73 | {"ALRM", SIGALRM}, |
73 | {"TERM", SIGTERM}, | 74 | {"TERM", SIGTERM}, |
74 | #if defined(__sparc__) || defined(__alpha__) | 75 | #if defined(__sparc__) || defined(__alpha__) |
75 | {"URG", SIGURG}, | 76 | {"URG", SIGURG}, |
76 | {"STOP", SIGSTOP}, | 77 | {"STOP", SIGSTOP}, |
77 | {"TSTP", SIGTSTP}, | 78 | {"TSTP", SIGTSTP}, |
78 | {"CONT", SIGCONT}, | 79 | {"CONT", SIGCONT}, |
79 | {"CHLD", SIGCHLD}, | 80 | {"CHLD", SIGCHLD}, |
80 | {"TTIN", SIGTTIN}, | 81 | {"TTIN", SIGTTIN}, |
81 | {"TTOU", SIGTTOU}, | 82 | {"TTOU", SIGTTOU}, |
82 | {"IO", SIGIO}, | 83 | {"IO", SIGIO}, |
83 | # ifndef __alpha__ | 84 | # ifndef __alpha__ |
84 | {"POLL", SIGIO}, | 85 | {"POLL", SIGIO}, |
85 | # endif | 86 | # endif |
86 | {"XCPU", SIGXCPU}, | 87 | {"XCPU", SIGXCPU}, |
87 | {"XFSZ", SIGXFSZ}, | 88 | {"XFSZ", SIGXFSZ}, |
88 | {"VTALRM", SIGVTALRM}, | 89 | {"VTALRM", SIGVTALRM}, |
89 | {"PROF", SIGPROF}, | 90 | {"PROF", SIGPROF}, |
90 | {"WINCH", SIGWINCH}, | 91 | {"WINCH", SIGWINCH}, |
91 | # ifdef __alpha__ | 92 | # ifdef __alpha__ |
92 | {"INFO", SIGINFO}, | 93 | {"INFO", SIGINFO}, |
93 | # else | 94 | # else |
94 | {"LOST", SIGLOST}, | 95 | {"LOST", SIGLOST}, |
95 | # endif | 96 | # endif |
96 | {"USR1", SIGUSR1}, | 97 | {"USR1", SIGUSR1}, |
97 | {"USR2", SIGUSR2}, | 98 | {"USR2", SIGUSR2}, |
98 | #else | 99 | #else |
99 | {"STKFLT", SIGSTKFLT}, | 100 | {"STKFLT", SIGSTKFLT}, |
100 | {"CHLD", SIGCHLD}, | 101 | {"CHLD", SIGCHLD}, |
101 | {"CONT", SIGCONT}, | 102 | {"CONT", SIGCONT}, |
102 | {"STOP", SIGSTOP}, | 103 | {"STOP", SIGSTOP}, |
103 | {"TSTP", SIGTSTP}, | 104 | {"TSTP", SIGTSTP}, |
104 | {"TTIN", SIGTTIN}, | 105 | {"TTIN", SIGTTIN}, |
105 | {"TTOU", SIGTTOU}, | 106 | {"TTOU", SIGTTOU}, |
106 | {"URG", SIGURG}, | 107 | {"URG", SIGURG}, |
107 | {"XCPU", SIGXCPU}, | 108 | {"XCPU", SIGXCPU}, |
108 | {"XFSZ", SIGXFSZ}, | 109 | {"XFSZ", SIGXFSZ}, |
109 | {"VTALRM", SIGVTALRM}, | 110 | {"VTALRM", SIGVTALRM}, |
110 | {"PROF", SIGPROF}, | 111 | {"PROF", SIGPROF}, |
111 | {"WINCH", SIGWINCH}, | 112 | {"WINCH", SIGWINCH}, |
112 | {"IO", SIGIO}, | 113 | {"IO", SIGIO}, |
113 | {"POLL", SIGPOLL}, | 114 | {"POLL", SIGPOLL}, |
114 | {"PWR", SIGPWR}, | 115 | {"PWR", SIGPWR}, |
115 | {"UNUSED", SIGUNUSED}, | 116 | {"UNUSED", SIGUNUSED}, |
116 | #endif | 117 | #endif |
117 | {0, 0} | 118 | {0, 0} |
118 | }; | 119 | }; |
119 | 120 | ||
120 | extern int kill_main (int argc, char **argv) | 121 | extern int kill_main(int argc, char **argv) |
121 | { | 122 | { |
122 | int sig = SIGTERM; | 123 | int sig = SIGTERM; |
123 | 124 | ||
124 | argc--; | 125 | argc--; |
125 | argv++; | 126 | argv++; |
126 | /* Parse any options */ | 127 | /* Parse any options */ |
127 | if (argc < 1) | 128 | if (argc < 1) |
128 | usage(kill_usage); | ||
129 | |||
130 | while (argc > 0 && **argv == '-') { | ||
131 | while (*++(*argv)) { | ||
132 | switch (**argv) { | ||
133 | case 'l': | ||
134 | { | ||
135 | int col=0; | ||
136 | const struct signal_name *s = signames; | ||
137 | |||
138 | while (s->name != 0) { | ||
139 | col+=fprintf(stderr, "%2d) %-8s", s->number, (s++)->name); | ||
140 | if (col>60) { | ||
141 | fprintf(stderr, "\n"); | ||
142 | col=0; | ||
143 | } | ||
144 | } | ||
145 | fprintf(stderr, "\n\n"); | ||
146 | exit( TRUE); | ||
147 | } | ||
148 | break; | ||
149 | case '-': | ||
150 | usage(kill_usage); | 129 | usage(kill_usage); |
151 | default: | 130 | |
152 | { | 131 | while (argc > 0 && **argv == '-') { |
153 | if (isdigit( **argv)) { | 132 | while (*++(*argv)) { |
154 | sig = atoi (*argv); | 133 | switch (**argv) { |
155 | if (sig < 0 || sig >= NSIG) | 134 | case 'l': |
156 | goto end; | 135 | { |
157 | else { | 136 | int col = 0; |
158 | argc--; | 137 | const struct signal_name *s = signames; |
159 | argv++; | 138 | |
160 | goto do_it_now; | 139 | while (s->name != 0) { |
161 | } | 140 | col += |
162 | } | 141 | fprintf(stderr, "%2d) %-8s", s->number, |
163 | else { | 142 | (s++)->name); |
164 | const struct signal_name *s = signames; | 143 | if (col > 60) { |
165 | while (s->name != 0) { | 144 | fprintf(stderr, "\n"); |
166 | if (strcasecmp (s->name, *argv) == 0) { | 145 | col = 0; |
167 | sig = s->number; | 146 | } |
168 | argc--; | 147 | } |
169 | argv++; | 148 | fprintf(stderr, "\n\n"); |
170 | goto do_it_now; | 149 | exit(TRUE); |
171 | } | 150 | } |
172 | s++; | 151 | break; |
152 | case '-': | ||
153 | usage(kill_usage); | ||
154 | default: | ||
155 | { | ||
156 | if (isdigit(**argv)) { | ||
157 | sig = atoi(*argv); | ||
158 | if (sig < 0 || sig >= NSIG) | ||
159 | goto end; | ||
160 | else { | ||
161 | argc--; | ||
162 | argv++; | ||
163 | goto do_it_now; | ||
164 | } | ||
165 | } else { | ||
166 | const struct signal_name *s = signames; | ||
167 | |||
168 | while (s->name != 0) { | ||
169 | if (strcasecmp(s->name, *argv) == 0) { | ||
170 | sig = s->number; | ||
171 | argc--; | ||
172 | argv++; | ||
173 | goto do_it_now; | ||
174 | } | ||
175 | s++; | ||
176 | } | ||
177 | if (s->name == 0) | ||
178 | goto end; | ||
179 | } | ||
180 | } | ||
173 | } | 181 | } |
174 | if (s->name == 0) | 182 | argc--; |
175 | goto end; | 183 | argv++; |
176 | } | ||
177 | } | 184 | } |
178 | } | ||
179 | argc--; | ||
180 | argv++; | ||
181 | } | ||
182 | } | ||
183 | |||
184 | do_it_now: | ||
185 | |||
186 | while (--argc >= 0) { | ||
187 | int pid; | ||
188 | struct stat statbuf; | ||
189 | char pidpath[20]="/proc/"; | ||
190 | |||
191 | if (! isdigit( **argv)) { | ||
192 | fprintf(stderr, "bad PID: %s\n", *argv); | ||
193 | exit( FALSE); | ||
194 | } | ||
195 | pid = atoi (*argv); | ||
196 | snprintf(pidpath, 20, "/proc/%s/stat", *argv); | ||
197 | if (stat( pidpath, &statbuf)!=0) { | ||
198 | fprintf(stderr, "kill: (%d) - No such pid\n", pid); | ||
199 | exit( FALSE); | ||
200 | } | 185 | } |
201 | fprintf(stderr, "sig = %d\n", sig); | ||
202 | if (kill (pid, sig) != 0) { | ||
203 | perror (*argv); | ||
204 | exit ( FALSE); | ||
205 | } | ||
206 | argv++; | ||
207 | } | ||
208 | exit ( TRUE); | ||
209 | 186 | ||
187 | do_it_now: | ||
210 | 188 | ||
211 | end: | 189 | while (--argc >= 0) { |
212 | fprintf(stderr, "bad signal name: %s\n", *argv); | 190 | int pid; |
213 | exit (TRUE); | 191 | struct stat statbuf; |
214 | } | 192 | char pidpath[20] = "/proc/"; |
193 | |||
194 | if (!isdigit(**argv)) { | ||
195 | fprintf(stderr, "bad PID: %s\n", *argv); | ||
196 | exit(FALSE); | ||
197 | } | ||
198 | pid = atoi(*argv); | ||
199 | snprintf(pidpath, 20, "/proc/%s/stat", *argv); | ||
200 | if (stat(pidpath, &statbuf) != 0) { | ||
201 | fprintf(stderr, "kill: (%d) - No such pid\n", pid); | ||
202 | exit(FALSE); | ||
203 | } | ||
204 | fprintf(stderr, "sig = %d\n", sig); | ||
205 | if (kill(pid, sig) != 0) { | ||
206 | perror(*argv); | ||
207 | exit(FALSE); | ||
208 | } | ||
209 | argv++; | ||
210 | } | ||
211 | exit(TRUE); | ||
215 | 212 | ||
216 | 213 | ||
214 | end: | ||
215 | fprintf(stderr, "bad signal name: %s\n", *argv); | ||
216 | exit(TRUE); | ||
217 | } | ||
diff --git a/procps/ps.c b/procps/ps.c index 4496faa31..207cdaa02 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * Mini ps implementation for busybox | 3 | * Mini ps implementation for busybox |
3 | * | 4 | * |
@@ -33,123 +34,128 @@ | |||
33 | #endif | 34 | #endif |
34 | 35 | ||
35 | typedef struct proc_s { | 36 | typedef struct proc_s { |
36 | char | 37 | char |
37 | cmd[16]; /* basename of executable file in call to exec(2) */ | 38 | cmd[16]; /* basename of executable file in call to exec(2) */ |
38 | int | 39 | int |
39 | ruid, rgid, /* real only (sorry) */ | 40 | ruid, rgid, /* real only (sorry) */ |
40 | pid, /* process id */ | 41 | pid, /* process id */ |
41 | ppid; /* pid of parent process */ | 42 | ppid; /* pid of parent process */ |
42 | char | 43 | char |
43 | state; /* single-char code for process state (S=sleeping) */ | 44 | state; /* single-char code for process state (S=sleeping) */ |
44 | } proc_t; | 45 | } proc_t; |
45 | 46 | ||
46 | 47 | ||
47 | 48 | ||
48 | static int file2str(char *filename, char *ret, int cap) | 49 | static int file2str(char *filename, char *ret, int cap) |
49 | { | 50 | { |
50 | int fd, num_read; | 51 | int fd, num_read; |
51 | 52 | ||
52 | if ( (fd = open(filename, O_RDONLY, 0)) == -1 ) return -1; | 53 | if ((fd = open(filename, O_RDONLY, 0)) == -1) |
53 | if ( (num_read = read(fd, ret, cap - 1)) <= 0 ) return -1; | 54 | return -1; |
54 | ret[num_read] = 0; | 55 | if ((num_read = read(fd, ret, cap - 1)) <= 0) |
55 | close(fd); | 56 | return -1; |
56 | return num_read; | 57 | ret[num_read] = 0; |
58 | close(fd); | ||
59 | return num_read; | ||
57 | } | 60 | } |
58 | 61 | ||
59 | 62 | ||
60 | static void parse_proc_status(char* S, proc_t* P) | 63 | static void parse_proc_status(char *S, proc_t * P) |
61 | { | 64 | { |
62 | char* tmp; | 65 | char *tmp; |
63 | memset(P->cmd, 0, sizeof P->cmd); | 66 | |
64 | sscanf (S, "Name:\t%15c", P->cmd); | 67 | memset(P->cmd, 0, sizeof P->cmd); |
65 | tmp = strchr(P->cmd,'\n'); | 68 | sscanf(S, "Name:\t%15c", P->cmd); |
66 | if (tmp) | 69 | tmp = strchr(P->cmd, '\n'); |
67 | *tmp='\0'; | 70 | if (tmp) |
68 | tmp = strstr (S,"State"); | 71 | *tmp = '\0'; |
69 | sscanf (tmp, "State:\t%c", &P->state); | 72 | tmp = strstr(S, "State"); |
70 | 73 | sscanf(tmp, "State:\t%c", &P->state); | |
71 | tmp = strstr (S,"Pid:"); | 74 | |
72 | if(tmp) sscanf (tmp, | 75 | tmp = strstr(S, "Pid:"); |
73 | "Pid:\t%d\n" | 76 | if (tmp) |
74 | "PPid:\t%d\n", | 77 | sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid); |
75 | &P->pid, | 78 | else |
76 | &P->ppid | 79 | fprintf(stderr, "Internal error!\n"); |
77 | ); | 80 | |
78 | else fprintf(stderr, "Internal error!\n"); | 81 | /* For busybox, ignoring effective, saved, etc */ |
79 | 82 | tmp = strstr(S, "Uid:"); | |
80 | /* For busybox, ignoring effective, saved, etc */ | 83 | if (tmp) |
81 | tmp = strstr (S,"Uid:"); | 84 | sscanf(tmp, "Uid:\t%d", &P->ruid); |
82 | if(tmp) sscanf (tmp, | 85 | else |
83 | "Uid:\t%d", &P->ruid); | 86 | fprintf(stderr, "Internal error!\n"); |
84 | else fprintf(stderr, "Internal error!\n"); | 87 | |
85 | 88 | tmp = strstr(S, "Gid:"); | |
86 | tmp = strstr (S,"Gid:"); | 89 | if (tmp) |
87 | if(tmp) sscanf (tmp, | 90 | sscanf(tmp, "Gid:\t%d", &P->rgid); |
88 | "Gid:\t%d", &P->rgid); | 91 | else |
89 | else fprintf(stderr, "Internal error!\n"); | 92 | fprintf(stderr, "Internal error!\n"); |
90 | 93 | ||
91 | } | 94 | } |
92 | 95 | ||
93 | 96 | ||
94 | extern int ps_main(int argc, char **argv) | 97 | extern int ps_main(int argc, char **argv) |
95 | { | 98 | { |
96 | proc_t p; | 99 | proc_t p; |
97 | DIR *dir; | 100 | DIR *dir; |
98 | FILE *file; | 101 | FILE *file; |
99 | struct dirent *entry; | 102 | struct dirent *entry; |
100 | char path[32], sbuf[512]; | 103 | char path[32], sbuf[512]; |
101 | char uidName[10]=""; | 104 | char uidName[10] = ""; |
102 | char groupName[10]=""; | 105 | char groupName[10] = ""; |
103 | int i, c; | 106 | int i, c; |
104 | 107 | ||
105 | if ( argc>1 && **(argv+1) == '-' ) { | 108 | if (argc > 1 && **(argv + 1) == '-') { |
106 | usage ("ps\n\nReport process status\n\nThis version of ps accepts no options.\n"); | 109 | usage |
107 | } | 110 | ("ps\n\nReport process status\n\nThis version of ps accepts no options.\n"); |
108 | |||
109 | dir = opendir("/proc"); | ||
110 | if (!dir) { | ||
111 | perror("Can't open /proc"); | ||
112 | exit(FALSE); | ||
113 | } | ||
114 | |||
115 | fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command"); | ||
116 | while ((entry = readdir(dir)) != NULL) { | ||
117 | uidName[0]='\0'; | ||
118 | groupName[0]='\0'; | ||
119 | |||
120 | if (! isdigit(*entry->d_name)) | ||
121 | continue; | ||
122 | sprintf(path, "/proc/%s/status", entry->d_name); | ||
123 | if ((file2str(path, sbuf, sizeof sbuf)) != -1 ) { | ||
124 | parse_proc_status(sbuf, &p); | ||
125 | } | 111 | } |
126 | 112 | ||
127 | /* Make some adjustments as needed */ | 113 | dir = opendir("/proc"); |
128 | my_getpwuid( uidName, p.ruid); | 114 | if (!dir) { |
129 | my_getgrgid( groupName, p.rgid); | 115 | perror("Can't open /proc"); |
130 | if (*uidName == '\0') | 116 | exit(FALSE); |
131 | sprintf( uidName, "%d", p.ruid); | ||
132 | if (*groupName == '\0') | ||
133 | sprintf( groupName, "%d", p.rgid); | ||
134 | |||
135 | fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName, p.state); | ||
136 | sprintf(path, "/proc/%s/cmdline", entry->d_name); | ||
137 | file = fopen(path, "r"); | ||
138 | if (file == NULL) { | ||
139 | perror(path); | ||
140 | exit(FALSE); | ||
141 | } | 117 | } |
142 | i=0; | 118 | |
143 | while (((c = getc(file)) != EOF) && (i < 53)) { | 119 | fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", |
144 | i++; | 120 | "State", "Command"); |
145 | if (c == '\0') | 121 | while ((entry = readdir(dir)) != NULL) { |
146 | c = ' '; | 122 | uidName[0] = '\0'; |
147 | putc(c, stdout); | 123 | groupName[0] = '\0'; |
124 | |||
125 | if (!isdigit(*entry->d_name)) | ||
126 | continue; | ||
127 | sprintf(path, "/proc/%s/status", entry->d_name); | ||
128 | if ((file2str(path, sbuf, sizeof sbuf)) != -1) { | ||
129 | parse_proc_status(sbuf, &p); | ||
130 | } | ||
131 | |||
132 | /* Make some adjustments as needed */ | ||
133 | my_getpwuid(uidName, p.ruid); | ||
134 | my_getgrgid(groupName, p.rgid); | ||
135 | if (*uidName == '\0') | ||
136 | sprintf(uidName, "%d", p.ruid); | ||
137 | if (*groupName == '\0') | ||
138 | sprintf(groupName, "%d", p.rgid); | ||
139 | |||
140 | fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName, | ||
141 | p.state); | ||
142 | sprintf(path, "/proc/%s/cmdline", entry->d_name); | ||
143 | file = fopen(path, "r"); | ||
144 | if (file == NULL) { | ||
145 | perror(path); | ||
146 | exit(FALSE); | ||
147 | } | ||
148 | i = 0; | ||
149 | while (((c = getc(file)) != EOF) && (i < 53)) { | ||
150 | i++; | ||
151 | if (c == '\0') | ||
152 | c = ' '; | ||
153 | putc(c, stdout); | ||
154 | } | ||
155 | if (i == 0) | ||
156 | fprintf(stdout, "%s", p.cmd); | ||
157 | fprintf(stdout, "\n"); | ||
148 | } | 158 | } |
149 | if (i==0) | 159 | closedir(dir); |
150 | fprintf(stdout, "%s", p.cmd); | 160 | exit(TRUE); |
151 | fprintf(stdout, "\n"); | ||
152 | } | ||
153 | closedir(dir); | ||
154 | exit(TRUE); | ||
155 | } | 161 | } |