diff options
author | Rob Landley <rob@landley.net> | 2015-03-13 21:33:34 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-03-13 21:33:34 -0500 |
commit | 98d8203cb85e1514bff1f654cb5636aeeb7c0df7 (patch) | |
tree | 560500618b2f8d331cc3f527b9dd8ebb1cf739ca /toys/pending/ps.c | |
parent | 438ad4ce2cffc27b2471b213c48f73375608510e (diff) | |
download | toybox-98d8203cb85e1514bff1f654cb5636aeeb7c0df7.tar.gz |
Minor ps refactoring.
Diffstat (limited to 'toys/pending/ps.c')
-rw-r--r-- | toys/pending/ps.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/toys/pending/ps.c b/toys/pending/ps.c index 1c002bbe..3e552574 100644 --- a/toys/pending/ps.c +++ b/toys/pending/ps.c @@ -38,10 +38,8 @@ struct header_list { int width, position; }; -/* - * create list of header attributes taking care of -o (-o ooid=MOM..) - * and width of attributes. - */ +// create list of header attributes taking care of -o (-o ooid=MOM..) +// and width of attributes. static void list_add(struct header_list *data, char *c_data) { struct header_list *temp = TT.o, *new = xzalloc(sizeof(struct header_list)); @@ -168,10 +166,7 @@ void get_time(unsigned long s_time, unsigned long u_time) free(temp); } -/* - * read command line taking care of in between NUL's - * in command line - */ +// read command line taking care of in between NUL's in command line static void read_cmdline(int fd, char *cmd_ptr) { int size = read(fd, cmd_ptr, BUFF_SIZE); //sizeof(cmd_buf) @@ -185,10 +180,8 @@ static void read_cmdline(int fd, char *cmd_ptr) } } -/* - * get the processes stats and print the stats - * corresponding to header attributes. - */ +// get the processes stats and print the stats +// corresponding to header attributes. static void do_ps_line(int pid, int tid) { char *stat_buff = toybuf + BUFF_SIZE, *cmd_buff = toybuf + (2*BUFF_SIZE); @@ -351,7 +344,7 @@ clean: free(name); } -//Do stats for threads (for -T option) +// Do stats for threads (for -T option) void do_ps_threads(int pid) { DIR *d; @@ -405,11 +398,10 @@ void ps_main(void) if (!(dp = opendir("/proc"))) perror_exit("opendir"); while ((entry = readdir(dp))) { - if (isdigit(*entry->d_name)) { - pid = atoi(entry->d_name); - do_ps_line(pid, 0); - if (toys.optflags & FLAG_T) do_ps_threads(pid); - } + if (!isdigit(*entry->d_name)) continue; + pid = atoi(entry->d_name); + do_ps_line(pid, 0); + if (toys.optflags & FLAG_T) do_ps_threads(pid); } closedir(dp); |