Bug #4694
closedsvcs(1) truncates contract ID
0%
Description
If a contract ID's decimal value exceeds 7 characters, svcs(1) will truncate it in the CTID column. In the following example, the correct CTID is found using 'ps -o ctid' and confirmed with mdb.
# svcs -Ho ctid noitd 1161696 # svcs -p noitd STATE STIME FMRI online 15:59:46 svc:/network/noitd:default 15:59:46 28267 noitd 15:59:46 28268 noitd # ps -o ctid -p 28267 CTID 11616969 # mdb -ke '0t28267::pid2proc | ::print proc_t p_ct_process | ::print -d struct cont_process conp_contract.ct_id' conp_contract.ct_id = 0t11616969
The relevant code is http://src.illumos.org/source/xref/illumos-gate/usr/src/cmd/svc/svcs/svcs.c#1004 where CTID_COLUMN_WIDTH is set to 6. As the contract ID is type ctid_t, which is type int, 6 characters is far too short.
Joyent has already fixed this: https://github.com/joyent/illumos-joyent/commit/010256d7d6b7086f9d35b1481095f6e792b0cc21 and I've basically pulled this fix straight in with the attached patch.
I've not done a webrev because this is a trivial 2-line fix. I have tested an updated svcs binary on OmniOS:
# /usr/bin/svcs.orig -Ho ctid noitd 1161888 # /usr/bin/svcs -Ho ctid noitd 11618880
My thanks to Robert Mustacchi and Dan McDonald for helping me track this down.
Files
Updated by Electric Monk about 9 years ago
git commit 51f825403978a9896925dd01602369a44b102c6d
Author: Eric Sproul <esproul@omniti.com> 4694 svcs(1) truncates contract ID Reviewed by: Garrett D'Amore <garrett@damore.org> Reviewed by: Dan McDonald <danmcd@omniti.com> Approved by: Gordon Ross <gordon.ross@nexenta.com>