Processes & Signals

0%
Processesprocessessignalsforkexeczombieorphanrenicebgfg

Processes & Signals

8 interactive questions

ProcessesQuestion
processessignalsforkexeczombieorphanrenicebgfg

SIGTERM vs SIGKILL?

Click to reveal answer
ProcessesAnswer

SIGTERM (15) politely asks a process to shut down — it can be caught to flush buffers, close connections, and exit cleanly. SIGKILL (9) is handled by the kernel, immediate, and cannot be caught, blocked, or ignored. Send TERM first; use -9 only if it won't exit. ⚠️ Force-killing risks corruption and lost locks.

ProcessesQuestion
processessignalsforkexeczombieorphanrenicebgfg

What is a signal? Name the ones you use most.

Click to reveal answer
ProcessesAnswer

An asynchronous notification the kernel delivers to a process. The three to know by number: SIGHUP (1) — originally "terminal hung up," now many daemons use it to reload config; SIGKILL (9) — uncatchable immediate kill; SIGTERM (15) — graceful shutdown. SIGHUP for reload vs restart is a favorite distinction.

ProcessesQuestion
processessignalsforkexeczombieorphanrenicebgfg

Process states R, S, D, Z?

Click to reveal answer
ProcessesAnswer

R running/runnable; S interruptible sleep (normal idle wait); D uninterruptible sleep (blocked in I/O, can't be killed until it returns); Z zombie (exited, parent hasn't reaped).

ProcessesQuestion
processessignalsforkexeczombieorphanrenicebgfg

What is a zombie process? How do you clean it up?

Click to reveal answer
ProcessesAnswer

A process that already exited but whose parent hasn't called wait() to read its status, so a Z entry lingers (using essentially no resources). ⚠️ You can't kill -9 a zombie — it's already dead. The fix is the parent: make it reap children (handle SIGCHLD) or restart it. A single zombie is harmless; a flood means a buggy parent.

ProcessesQuestion
processessignalsforkexeczombieorphanrenicebgfg

Zombie vs orphan?

Click to reveal answer
ProcessesAnswer

Zombie = child exited, parent didn't reap it. Orphan = parent died first, so the child is re-parented to PID 1 (systemd), which reaps it when it exits. Orphans are handled automatically; zombies signal a parent bug.

ProcessesQuestion
processessignalsforkexeczombieorphanrenicebgfg

fork vs exec?

Click to reveal answer
ProcessesAnswer

fork() creates a near-identical copy of the calling process (new PID). execve() replaces the current process image with a new program. The shell runs commands by fork then exec. 🎯 This is why a subshell's cd doesn't affect the parent.

ProcessesQuestion
processessignalsforkexeczombieorphanrenicebgfg

How do you send a running foreground command to the background?

Click to reveal answer
ProcessesAnswer

Ctrl+Z suspends it, bg resumes it in the background; jobs lists, fg %1 foregrounds. Or start with cmd &. ⚠️ Shell jobs die on logout — for durable work use nohup, tmux/screen, or a systemd unit with proper logging and restart policy.

ProcessesQuestion
processessignalsforkexeczombieorphanrenicebgfg

How do you lower a noisy process's CPU priority?

Click to reveal answer
ProcessesAnswer

renice -n 10 -p <PID> raises its nice value (lower priority). Nice ranges −20 (highest) to 19 (lowest); only root can set negative. 🎯 renice is a hint to the scheduler — for a hard cap on shared hosts use cgroup CPUQuota= instead.