Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

464 Daemon Processes Chapter 13


Under System V–based systems, a similar command isps -efj.(In an attempt to
improve security,some UNIX systems don’t allow us to usepsto look at any processes
other than our own.) The output frompslooks like

UID PID PPID PGID SID TTY CMD
root 1 011 ?/sbin/init
root 2 000 ?[kthreadd]
root 3 200 ?[ksoftirqd/0]
root 6 200 ?[migration/0]
root 7 200 ?[watchdog/0]
root 21 200 ?[cpuset]
root 22 200 ?[khelper]
root 26 200 ?[sync_supers]
root 27 200 ?[bdi-default]
root 29 200 ?[kblockd]
root 35 200 ?[kswapd0]
root 49 200 ?[scsi_eh_0]
root 256 200 ?[jbd2/sda5-8]
root 257 200 ?[ext4-dio-unwrit]
syslog 847 18 43 843 ?rsyslogd -c5
root 906 19 06 906 ?/usr/sbin/cupsd -F
root 1037 1 1037 1037? /usr/sbin/inetd
root 1067 1 1067 1067? cron
daemon 1068 11068 1068? atd
root 8196 1 8196 8196? /usr/sbin/sshd -D
root 13047 200 ?[kworker/1:0]
root 14596 200 ?[flush-8:0]
root 26464 126464 26464 ?rpcbind -w
statd 28490 128490 28490 ?rpc.statd -L
root 28553 200 ?[rpciod]
root 28554 200 ?[nfsiod]
root 28561 128561 28561 ?rpc.idmapd
root 28761 200 ?[lockd]
root 28764 200 ?[nfsd]
root 28775 128775 28775 ?/usr/sbin/rpc.mountd --manage-gids

We have removed a few columns that don’t interest us, such as the accumulated CPU
time. The column headings, in order,are the user ID, process ID, parent process ID,
process group ID, session ID, terminal name, and command string.

The system that thispscommand was run on(Linux 3.2.0)supports the notion of a session ID,
which we mentioned with thesetsidfunction in Section 9.5. The session ID is simply the
process ID of the session leader.Some BSD-based systems, such as Mac OS X 10.6.8, will print
the address of thesessionstructurecorresponding to the process group that the process
belongs to (Section 9.11) instead of the session ID.

The system processes you see will depend on the operating system implementation.
Anything with a parent process ID of 0 is usually a kernel process started as part of the
system bootstrap procedure. (An exception isinit,which is a user-level command
started by the kernel at boot time.) Kernel processes arespecial and generally exist for
the entirelifetime of the system. They run with superuser privileges and have no
controlling terminal and no command line.
Free download pdf