Opened 11 years ago

Closed 11 years ago

#10156 closed enhancement (fixed)

[ps] Implement -o option to customize the program output

Reported by: diger Owned by: siarzhuk
Priority: normal Milestone: R1
Component: Applications/Command Line Tools Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by siarzhuk)

It should help in porting shell scripts to have possibility to customize the ps tool output with the -o option as is implemented in other operation systems. For example current output:

/boot> ps
Team                                                  Id #Threads  Gid  Uid
kernel_team                                            1       50    0    0
/boot/apps/Pe/Pe                                  156192        7    0    0
/boot/apps/WebPositive                            176176        7    0    0

can be customized as follows:

/boot> ps -o Id,Team
    Id                 Team
     1                 kernel_team
156192                 /boot/apps/Pe/Pe
176176                 /boot/apps/WebPositive

Attachments (1)

0001-ps-Support-o-option.patch (6.7 KB ) - added by ThomasCompix 11 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by siarzhuk, 11 years ago

Description: modified (diff)
Summary: Implement -o option to customize the program output[ps] Implement -o option to customize the program output

comment:2 by siarzhuk, 11 years ago

Owner: changed from nobody to siarzhuk
Status: newassigned

Going to publish this as GCI 2013 task.

comment:3 by ThomasCompix, 11 years ago

patch: 01

in reply to:  3 comment:4 by ThomasCompix, 11 years ago

Replying to ThomasCompix:

I just uploaded the patch. I hope the Author section is formatted correctly now.

comment:5 by korli, 11 years ago

Review:

  • include header are alphabetically sorted.
  • two blank lines between functions
  • struct option { => "{" goes next line.
  • while (printCustomized[printCustomizedPos]) { should be while (printCustomized[printCustomizedPos] != '\0') {
  • if (printCustomized[printCustomizedPos] == ',') printCustomizedPos++; should be tabbed to the right.
  • for (int i = 0; sOptions[i].id; ++i) { should be for (int i = 0; sOptions[i].id != 0; i++) {

See also http://pubs.opengroup.org/onlinepubs/007904975/utilities/ps.html One is supposed to be able to rename a column with -o Team=Process. Multiple -o options are also possible. Might be out of the scope of this task/enhancement.

comment:6 by ThomasCompix, 11 years ago

Thanks for your review.

I am going to fix the styling mistakes and provide you with a new patch. If you wish I could try to add the behaviours you described at the end.

The support of multiple -o should not be a problem I guess. Same for the rename, as long as you can tell me what formats it is to support. Supporting something like this...

ps -o Id -o Team=Process,Threads

.. should be fine, but I wouldn't know how to handle a space in the rename actually.

by ThomasCompix, 11 years ago

in reply to:  6 comment:7 by siarzhuk, 11 years ago

Replying to ThomasCompix:

Thanks for your review.

Thanks for continuing "support" after corresponding task was marked as complete. The objective of the task was implementing -o option - and now it is complete. You are in the contest now so feel free to spend 100% of your time on other tasks and improving your personal rating. ;-)

PS: May be, if we have enough ideas for further ps improvements - it can be published as the new GCI task some time later.

comment:8 by siarzhuk, 11 years ago

Resolution: fixed
Status: assignedclosed

Implemented in hrev46520 during GCI 2013. Thanks!

Note: See TracTickets for help on using tickets.