5

ps(1), with the -f option, will output processes for which there is no associated command line in square brackets, like so:

UID PID PPID C STIME TTY TIME CMD root 1 0 0 Aug28 ? 00:07:42 /sbin/init root 2 0 0 Aug28 ? 00:00:01 [kthreadd] root 3 2 0 Aug28 ? 00:00:00 [rcu_gp] root 4 2 0 Aug28 ? 00:00:00 [rcu_par_gp] root 6 2 0 Aug28 ? 00:00:00 [kworker/0:0H-kblockd] root 8 2 0 Aug28 ? 00:00:00 [mm_percpu_wq] root 9 2 0 Aug28 ? 00:02:14 [ksoftirqd/0] root 10 2 0 Aug28 ? 00:05:33 [rcu_preempt] root 11 2 0 Aug28 ? 00:01:36 [rcuc/0] root 12 2 0 Aug28 ? 00:00:00 [rcub/0] root 13 2 0 Aug28 ? 00:00:07 [migration/0] root 14 2 0 Aug28 ? 00:00:00 [idle_inject/0] root 16 2 0 Aug28 ? 00:00:00 [cpuhp/0] root 17 2 0 Aug28 ? 00:00:00 [cpuhp/1] root 18 2 0 Aug28 ? 00:00:00 [idle_inject/1] root 19 2 0 Aug28 ? 00:00:05 [migration/1] root 20 2 0 Aug28 ? 00:00:55 [rcuc/1] 

Are these processes scheduled like other processes?

2
  • Those "processes for which they is no associated command line" are usually referred to as "kernel threads". Commented Oct 26, 2019 at 4:03
  • 1
    @JosephSible Usually, but not always. One example, userspace processes that became defunct will have square brackets around them. Commented Oct 26, 2019 at 4:18

1 Answer 1

6

Under Linux, ps and top handle information made available by the kernel in /proc, for each process, in a directory named after the pid. This includes two files, comm and cmdline; comm is the process’s command name, and cmdline is the process’s command line, i.e. the arguments it was provided with (including its own “name”). ps and top use square brackets to distinguish between the two: if a process has a command line, then the args field (also known as CMD) outputs that; otherwise it outputs the command name, surrounded with square brackets.

This is described in the ps manpage, for args:

Sometimes the process args will be unavailable; when this happens, ps will instead print the executable name in brackets.

Processes without process arguments include processes constructed without any command line (not even argv[0]), such as kernel threads, and processes which have lost their command line, i.e. defunct processes, also known as zombies (identifiable by the <defunct> suffix).

None of this changes the scheduling properties: all processes are scheduled in the same way, according to their state, priority, etc.

2
  • 2
    It also includes processes that have executed a command without argument, not even argv[0] (which usually doesn't happen). Try with perl -e 'exec {"/bin/sh"} ()' for instance. Commented Oct 29, 2019 at 9:19
  • Both comm and cmdline are modifiable in Linux. The first via a prctl(PR_SET_NAME), the second by just overwriting the argv strings in process memory. Commented Aug 19, 2020 at 13:53

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.