Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115568165
D49615.id152975.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D49615.id152975.diff
View Options
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -96,6 +96,7 @@
};
struct velisthead varlist = STAILQ_HEAD_INITIALIZER(varlist);
+static struct velisthead Ovarlist = STAILQ_HEAD_INITIALIZER(Ovarlist);
static kvm_t *kd;
static int needcomm; /* -o "command" */
@@ -151,8 +152,6 @@
static const char jfmt[] = "user,pid,ppid,pgid,sid,jobc,state,tt,time,command";
static const char lfmt[] = "uid,pid,ppid,cpu,pri,nice,vsz,rss,mwchan,state,"
"tt,time,command";
-static const char o1[] = "pid";
-static const char o2[] = "tt,state,time,command";
static const char ufmt[] = "user,pid,%cpu,%mem,vsz,rss,tt,state,start,time,command";
static const char vfmt[] = "pid,state,time,sl,re,pagein,vsz,rss,lim,tsiz,"
"%cpu,%mem,command";
@@ -327,10 +326,7 @@
nlistf = optarg;
break;
case 'O':
- parsefmt(o1, &varlist, 1);
- parsefmt(optarg, &varlist, 1);
- parsefmt(o2, &varlist, 1);
- _fmt = 1;
+ parsefmt(optarg, &Ovarlist, 1);
break;
case 'o':
parsefmt(optarg, &varlist, 1);
@@ -464,6 +460,26 @@
if (!_fmt)
parsefmt(dfmt, &varlist, 0);
+ if (!STAILQ_EMPTY(&Ovarlist)) {
+ VARENT *const pid_entry = find_varentry("pid");
+
+ /*
+ * We insert the keywords passed by '-O' after the process ID if
+ * specified, else at start.
+ */
+ if (pid_entry != NULL) {
+ struct velisthead rest;
+
+ STAILQ_SPLIT_AFTER(&varlist, pid_entry, &rest, next_ve);
+ STAILQ_CONCAT(&varlist, &Ovarlist);
+ STAILQ_CONCAT(&varlist, &rest);
+ }
+ else {
+ STAILQ_SWAP(&varlist, &Ovarlist, varent);
+ STAILQ_CONCAT(&varlist, &Ovarlist);
+ }
+ }
+
keywords_info = calloc(known_keywords_nb, sizeof(struct keyword_info));
if (keywords_info == NULL)
xo_errx(1, "malloc failed");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 26, 11:01 AM (13 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17377385
Default Alt Text
D49615.id152975.diff (1 KB)
Attached To
Mode
D49615: ps(1): Make '-O' more versatile and predictable
Attached
Detach File
Event Timeline
Log In to Comment