1

In the manpage of ps

-j Jobs format.

-f Do full-format listing.

-o format User-defined format.

$ ps -j -o ppid,sid
error: can not use output modifiers with user-defined output

$ ps -f -o ppid,sid
 PPID   SID
 3046 23122
 3046  1002
 1002  1002
 3046 13961
...

What does output modifiers mean? In the manpage of ps, -j,-f and -o are listed under OUTPUT FORMAT CONTROL, instead of OUTPUT MODIFIERS.

Generally speaking, how are output modifiers used, compared to output format control options?

Are output modifiers options or arguments?

4
  • -j asks for output in "jobs format", and -o ppid,sid ask for output in "custom format". Which one do you want? Commented Feb 28, 2016 at 4:29
  • Their union? why ps -f -o ppid,sid works without error? Commented Feb 28, 2016 at 4:31
  • Yes, but -f has no impact. It should probably give an error too. Though I agree a "union" of formats could have been useful. I'm guessing you want to see -oppid,pid,pgid,sid,tty,time,cmd Commented Feb 28, 2016 at 4:42
  • Not really. I made up the examples. I want to understand: What does "output modifiers" mean? how are output modifiers used, compared to output format control options? Are output modifiers options or arguments? Commented Feb 28, 2016 at 4:48

1 Answer 1

1

It seems to be a misleading error message.

If you look at the procps source, file common.h line 290:

extern unsigned        format_modifiers; /* -c -j -y -P -L... */

-j implied format_modifiers flag to be set, which cause the error if used with user defined output:

if(format_list){
  if(format_flags) return "Conflicting format options.";
  if(format_modifiers) return "Can't use output modifiers with user-defined output";
  if(thread_flags&TF_must_use) return "-L/-T with H/m/-m and -o/-O/o/O is nonsense";
  return NULL;
}

A message like Can't use output format modifiers with user-defined output would be better.


FreeBSD ps doesn't have this issue, -j option cause ps to print information about user, pid, ppid, pgid, sid, jobc, state, tt, time, and command. Adding -o makes the output aggregated:

$ ps -j -o ppid,sid
USER     PID PPID PGID  SID JOBC STAT TT     TIME COMMAND          PPID  SID
cuonglm 1196 1195 1196 1196    0 Ss    0  0:00.02 -sh (sh)         1195 1196
cuonglm 1233 1196 1233 1196    1 R+    0  0:00.00 ps -j -o ppid,si 1196 1196

Output modifiers control how information displayed, while output format controls control what information displayed.

Example the s options is an output format control, because it added process signal information to ps output:

$ ps s
  UID   PID          PENDING          BLOCKED          IGNORED           CAUGHT STAT TTY        TIME COMMAND
 1000 12831 0000000000000000 0000000000000002 0000000000384004 0000000188013003 Ss   pts/1      0:00 zsh
 1000 13067 0000000000000000 0000000000000000 0000000000000000 0000000073d3fef9 R+   pts/1      0:00 ps s

f is an output modifier, because it changed how the output displayed:

$ ps f
  PID TTY      STAT   TIME COMMAND
12831 pts/1    Ss     0:00 zsh
13238 pts/1    R+     0:00  \_ ps f

Here the output was displayed as hierarchy.

8
  • Thanks. What does "output modifiers" mean? how are output modifiers used, compared to output format control options? Are output modifiers options or arguments? Commented Feb 28, 2016 at 17:19
  • Did you read the last part of my answer? What do you mean options and arguments? Commented Feb 28, 2016 at 17:37
  • Sorry, I missed your last part. Are output modifiers options or non-option arguments? Commented Feb 28, 2016 at 17:58
  • They are both options arguments Commented Feb 28, 2016 at 22:32
  • Thanks. (1) In the manpage of ps, -j means jobs format, and is listed under OUTPUT FORMAT CONTROL, instead of OUTPUT MODIFIERS. Your reply says that the source code says -j is format modifier. Is -j jobs format or format modifier? (2) -f is also listed under output format control in ps manpage. Why -f can work with -o, while -j can't? Commented Feb 29, 2016 at 22:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.