diff options
Diffstat (limited to 'procps')
-rw-r--r-- | procps/ps.c | 19 | ||||
-rw-r--r-- | procps/uptime.c | 8 |
2 files changed, 12 insertions, 15 deletions
diff --git a/procps/ps.c b/procps/ps.c index 2b41a495f..ec63bb548 100644 --- a/procps/ps.c +++ b/procps/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 | ||
diff --git a/procps/uptime.c b/procps/uptime.c index 159f24baa..fb3d347c3 100644 --- a/procps/uptime.c +++ b/procps/uptime.c | |||
@@ -51,19 +51,19 @@ extern int uptime_main(int argc, char **argv) | |||
51 | 51 | ||
52 | sysinfo(&info); | 52 | sysinfo(&info); |
53 | 53 | ||
54 | fprintf(stdout, " %2d:%02d%s up ", | 54 | printf(" %2d:%02d%s up ", |
55 | current_time->tm_hour%12 ? current_time->tm_hour%12 : 12, | 55 | current_time->tm_hour%12 ? current_time->tm_hour%12 : 12, |
56 | current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am"); | 56 | current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am"); |
57 | updays = (int) info.uptime / (60*60*24); | 57 | updays = (int) info.uptime / (60*60*24); |
58 | if (updays) | 58 | if (updays) |
59 | fprintf(stdout, "%d day%s, ", updays, (updays != 1) ? "s" : ""); | 59 | printf("%d day%s, ", updays, (updays != 1) ? "s" : ""); |
60 | upminutes = (int) info.uptime / 60; | 60 | upminutes = (int) info.uptime / 60; |
61 | uphours = (upminutes / 60) % 24; | 61 | uphours = (upminutes / 60) % 24; |
62 | upminutes %= 60; | 62 | upminutes %= 60; |
63 | if(uphours) | 63 | if(uphours) |
64 | fprintf(stdout, "%2d:%02d, ", uphours, upminutes); | 64 | printf("%2d:%02d, ", uphours, upminutes); |
65 | else | 65 | else |
66 | fprintf(stdout, "%d min, ", upminutes); | 66 | printf("%d min, ", upminutes); |
67 | 67 | ||
68 | printf("load average: %ld.%02ld, %ld.%02ld, %ld.%02ld\n", | 68 | printf("load average: %ld.%02ld, %ld.%02ld, %ld.%02ld\n", |
69 | LOAD_INT(info.loads[0]), LOAD_FRAC(info.loads[0]), | 69 | LOAD_INT(info.loads[0]), LOAD_FRAC(info.loads[0]), |