CIS241

System-Level Programming and Utilities

Linux Processes

Erik Fredericks, frederer@gvsu.edu
Fall 2025

Based on material provided by Erin Carrier, Austin Ferguson, and Katherine Bowers

CIS241 | Fredericks | F25 | 19-processes

What is a process?

  • Execution of a program/command

    • Or, something running in memory!
  • User process

    • Process begun by a user on a terminal
  • Daemon process

    • System process
    • Not associated with a terminal
CIS241 | Fredericks | F25 | 19-processes

Viewing processes

  • ps - list active processes
  • ps -f - more information
  • ps -u - what processes am I running?
  • top - interactive
    • If installed, htop even more interactive
CIS241 | Fredericks | F25 | 19-processes

Processes and Terms

Process ID (PID)

  • Unique identifier assigned to a process

Child process

  • Process started by another process (parent process)

Parent process

  • Process that has started other processes (child processes)

Parent Process ID (PPID)

  • PID of the parent process

The init daemon has a PID of 1 and a PPID of 0
0 refers to the kernel itself

bottom-corner (parent and child)

.
(process tree)

Process tree

 
 
 
 
 
 
 
 
 
 
 

pstree

.

Processes

init daemon

  • Starts most other daemons during the system initialization process
  • Including those that allow for user logins

The login program starts a bash shell

  • bash shell then interprets user commands and starts all user processes
  • Each process on the Linux system can be traced back to the init daemon by examining PPIDs
.

Processes

Process state (ps aux or ps -l)

  • Current processor state of process
  • Generally sleeping (S) or running (R)
  • This column is the most valuable to system administrators

Zombie process

  • Process finished, but parent has not released child process’s PID
  • Defunct process
  • Process state is Z

bottom-right (zombie penguin)

.

Foreground and background

Processes typically run in the foreground when you launch them

  • Takes over the shell until completed!
  • Kind of annoying if you want to do other things...
  • To suspend a running process: Ctrl + Z

  • To resume suspended process in foreground: fg

  • To resume suspended process in background: bg

  • jobs to show foreground, background, and suspended processes!

  • Can also run in background immediately: command &

.

Stopping a process

In the foreground (running)

  • Ctrl + c

In the background

  • kill pid - stop gracefully -- lookup with ps
    • What is gracefully?
  • kill -9 pid - force kill - stop immediately!
  • killall processname - kills ALL processes with processname (typically requires sudo)
.

Stopping a process

64 different types of kill signals!

  • Why?
.
(kill signals)
.

Killing processes

Trap: the ability of a process to ignore a kill signal

  • The SIGKILL signal cannot be trapped by any process
  • Use only as last resort because it prevents a process from closing temporary files and resources properly

When a parent process receives a kill signal

  • Terminates all child processes before terminating self
  • To kill several related processes send signal to parent process
  • Kill parent process in order to kill zombie processes

top-corner (penguin friends)

.

http://1.bp.blogspot.com/_doukgd8PkSU/SoqMf8ulMlI/AAAAAAAAAoU/018wijSVWI8/s320/ZombiePenguin.jpg

make a bash forever script: #!/bin/bash i=0 while : do echo $i i=$((i + 1)) sleep 1 done put into bg - jobs - fg 1 (if 1)