aboutsummaryrefslogtreecommitdiff
path: root/ps.c
diff options
context:
space:
mode:
Diffstat (limited to 'ps.c')
-rw-r--r--ps.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/ps.c b/ps.c
index 2b41a495f..ec63bb548 100644
--- a/ps.c
+++ b/ps.c
@@ -143,8 +143,7 @@ extern int ps_main(int argc, char **argv)
143 terminal_width = win.ws_col - 1; 143 terminal_width = win.ws_col - 1;
144#endif 144#endif
145 145
146 fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", 146 printf("%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command");
147 "State", "Command");
148 while ((entry = readdir(dir)) != NULL) { 147 while ((entry = readdir(dir)) != NULL) {
149 if (!isdigit(*entry->d_name)) 148 if (!isdigit(*entry->d_name))
150 continue; 149 continue;
@@ -166,8 +165,7 @@ extern int ps_main(int argc, char **argv)
166 if (file == NULL) 165 if (file == NULL)
167 continue; 166 continue;
168 i = 0; 167 i = 0;
169 len = fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName, 168 len = printf("%5d %-8s %-8s %c ", p.pid, uidName, groupName, p.state);
170 p.state);
171 while (((c = getc(file)) != EOF) && (i < (terminal_width-len))) { 169 while (((c = getc(file)) != EOF) && (i < (terminal_width-len))) {
172 i++; 170 i++;
173 if (c == '\0') 171 if (c == '\0')
@@ -176,8 +174,8 @@ extern int ps_main(int argc, char **argv)
176 } 174 }
177 fclose(file); 175 fclose(file);
178 if (i == 0) 176 if (i == 0)
179 fprintf(stdout, "[%s]", p.cmd); 177 printf("[%s]", p.cmd);
180 fprintf(stdout, "\n"); 178 putchar('\n');
181 } 179 }
182 closedir(dir); 180 closedir(dir);
183 return EXIT_SUCCESS; 181 return EXIT_SUCCESS;
@@ -240,8 +238,7 @@ extern int ps_main(int argc, char **argv)
240#endif 238#endif
241 239
242 /* Print up a ps listing */ 240 /* Print up a ps listing */
243 fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", 241 printf("%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command");
244 "State", "Command");
245 242
246 for (i=1; i<pid_array[0] ; i++) { 243 for (i=1; i<pid_array[0] ; i++) {
247 info.pid = pid_array[i]; 244 info.pid = pid_array[i];
@@ -257,7 +254,7 @@ extern int ps_main(int argc, char **argv)
257 if (*groupName == '\0') 254 if (*groupName == '\0')
258 sprintf(groupName, "%ld", info.egid); 255 sprintf(groupName, "%ld", info.egid);
259 256
260 len = fprintf(stdout, "%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state); 257 len = printf("%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state);
261 258
262 if (strlen(info.command_line) > 1) { 259 if (strlen(info.command_line) > 1) {
263 for( j=0; j<(sizeof(info.command_line)-1) && j < (terminal_width-len); j++) { 260 for( j=0; j<(sizeof(info.command_line)-1) && j < (terminal_width-len); j++) {
@@ -266,9 +263,9 @@ extern int ps_main(int argc, char **argv)
266 } 263 }
267 } 264 }
268 *(info.command_line+j) = '\0'; 265 *(info.command_line+j) = '\0';
269 fprintf(stdout, "%s\n", info.command_line); 266 puts(info.command_line);
270 } else { 267 } else {
271 fprintf(stdout, "[%s]\n", info.name); 268 printf("[%s]\n", info.name);
272 } 269 }
273 } 270 }
274 271