• Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created about 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A small utility for listing and reaping zombie processes on GNU/Linux.

Logo

zps Release

A small utility for listing and reaping zombie processes on GNU/Linux.

zps

Build Docker Build Codacy Codecov Stars License

On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution (via the exit system call) but still has an entry in the process table. This occurs for child processes, where the entry is still needed to allow the parent process to read its child's exit status: once the exit status is read via the wait system call, the zombie's entry is removed from the process table and it is said to be "reaped".

Unlike the normal processes, zombie processes cannot be removed from a system with the kill command since they are already dead. (This is where the term's metaphor [zombie - an undead person] comes from.) To reap a zombie process, SIGCHLD signal can be sent to the parent process manually using the kill command. If the parent process refuses to reap the zombie, then terminating the parent process (mostly with SIGTERM signal) can be an option. When a child process loses its parent, init process becomes its new parent and it will reap any zombies since it executes the wait system call periodically.

Zombie processes are not harmful since they are not affecting other processes or using any system resources. However, they do retain their process ID. This can lead to preventing new processes to launch if all the available PIDs were assigned to zombie processes. Considering Unix-like systems have a finite number of process IDs (/proc/sys/kernel/pid_max), it's one of the problems that zombie processes can cause. Another danger of zombie processes is that they can cause resource leak if they stay as a zombie in the process table for a long time. Apart from these issues, having a few zombie processes won't be a big deal for the system although they might indicate a bug with their parent process.

zproc.c file can be compiled and run to see how zombie processes are created.

cd example/ && gcc -O3 -Wall zproc.c -o zproc && ./zproc

zps aims to list the running processes at a particular time with stats and indicate the zombie processes on this list. It can also reap these zombie processes automatically if --reap argument is provided. There's also --lreap argument for reaping zombie processes after listing. See usage for more information.
Technically, zps reads process stats from /proc filesystem and uses C POSIX library to handle listing, sending signals and other operations.

Installation

Arch Linux

pacman -S zps

Fedora Linux

dnf install zps

CMake

mkdir -p build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
sudo ldconfig

Make

make
sudo make install

GCC

cd src/ && gcc -s -O3 -Wall -Wextra -pedantic zps.c -o zps

Docker

Building an image

docker build -f docker/Dockerfile -t zps .

Running the image in container

docker run zps

Usage

Usage:
  zps [options]

Options:
  -r, --reap      reap zombie processes
  -x, --lreap     list and reap zombie processes
  -l, --list      list zombie processes only
  -p, --prompt    show prompt for selecting processes
  -f, --fd <num>  set maximum file descriptors (default: 15)
  -s, --silent    run in silent mode
  -v, --version   show version
  -h, --help      show help

zps -r

zps -r

zps -x

zps -x

zps -l

zps -l

zps -p

zps -p

TODO(s)

  • Improve listing processes for long process names.
  • Send SIGCHLD signal to the parent instead of terminating it.

License

GNU General Public License v3.0 only (GPL-3.0-only)

Copyright

Copyright ยฉ 2019-2023, Orhun Parmaksฤฑz

More Repositories

1

git-cliff

A highly customizable Changelog Generator that follows Conventional Commit specifications โ›ฐ๏ธ
Rust
5,800
star
2

kmon

Linux Kernel Manager and Activity Monitor ๐Ÿง๐Ÿ’ป
Rust
1,911
star
3

systeroid

A more powerful alternative to sysctl(8) with a terminal user interface ๐Ÿง
Rust
997
star
4

gpg-tui

Manage your GnuPG keys with ease! ๐Ÿ”
Rust
991
star
5

rustypaste

A minimal file upload/pastebin service.
Rust
757
star
6

halp

A CLI tool to get help with CLI tools ๐Ÿ™
Rust
597
star
7

menyoki

Screen{shot,cast} and perform ImageOps on the command line ๐ŸŒฑ ๐Ÿž๏ธ
Rust
489
star
8

linuxwave

Generate music from the entropy of Linux ๐Ÿง๐ŸŽต
Zig
399
star
9

pkgtop

Interactive package manager and resource monitor designed for the GNU/Linux.
Go
268
star
10

runst

A dead simple notification daemon ๐Ÿฆก
Rust
234
star
11

CoolModFiles

A web player that plays some cool MOD files randomly ๐ŸŽถ
JavaScript
132
star
12

kermit

A VTE-based, simple and froggy terminal emulator ๐Ÿธ
C
114
star
13

rust-tui-template

A template for bootstrapping a Rust TUI application with tui-rs & crossterm
Rust
77
star
14

dotfiles

Orhun's Arch Linux configuration files and scripts ๐Ÿ 
Shell
70
star
15

godsays

Rust port of the Terry Davis' (RIP) "god says" program
Rust
69
star
16

rtl_map

FFT-based visualizer for RTL-SDR devices. (RTL2832/DVB-T)
C
67
star
17

battleship-rs

Battleship game implemented in Rust
Rust
65
star
18

git-cliff-action

GitHub action to generate a changelog based on the Git history
Shell
65
star
19

rustypaste-cli

A CLI tool for rustypaste
Rust
56
star
20

k3pler

Android network connection blocker and packet analyzer built on top of local HTTP proxy.
Java
48
star
21

orhun

My GitHub profile README.md โญ:octocat:
41
star
22

ApkServInject

Tool for injecting (smali) services to APK files
Java
30
star
23

cargo-nocode

Cargo subcommand to easily bootstrap nocode applications. Write nothing; deploy nowhere.
Rust
29
star
24

god

Linux utility for simplifying the Git usage.
Go
25
star
25

dnsleaktest-tui

A proof-of-concept TUI for testing DNS leaks & running traceroute
Rust
20
star
26

PSAUX

Android task manager and automated background service killer.
Java
20
star
27

alpkg

Set up Alpine Linux packaging environment with a breeze! ๐Ÿ”
Shell
18
star
28

packaging-rust-for-npm

https://blog.orhun.dev/packaging-rust-for-npm/
JavaScript
17
star
29

Picasso

PIC16F877A based 5V/20MHz development board and PIC programmer
C
15
star
30

PKGBUILDs

Arch Linux packages that I maintain ๐Ÿ”ง
Shell
13
star
31

personal-blog

The source of my blog โœ๐Ÿผ
SCSS
13
star
32

dialogflowbot

Google's Dialogflow implementation on Android with additional features.
Java
11
star
33

i3-workspace-brightness

Utility to auto-adjust the brightness of i3wm workspaces
Rust
11
star
34

Black-Waves

A wavy dark theme for VSCode
10
star
35

HydropotX

Automated and Self-contained Hydroponics System ๐ŸŒฑ
Kotlin
9
star
36

advent-of-code

My Advent of Code solutions ๐Ÿข
Rust
8
star
37

Last-Commit

A VSCode extension that focuses on the last git commit
JavaScript
7
star
38

zig-http-benchmarks

Benchmarking Zig HTTP client against Rust, Go, Python and curl
Zig
6
star
39

binsider

Analyze ELF binaries like a boss (WIP)
Rust
4
star
40

orhun.github.io

Personal website
HTML
4
star
41

theattyr

A terminal theatre for playing VT100 art and animations
Rust
4
star
42

godsings

https://melody.godsays.xyz
Python
3
star
43

base16-kermit

Base16 for kermit
Mustache
3
star
44

parseit

A simple text file parsing library powered by regex and glob patterns
Rust
3
star
45

typewriter

Turn your keyboard into a typewriter (WIP)
Rust
2
star
46

firebox-auth-cracker

A CLI tool to brute force the authentication signature of WatchGuard's Firebox
Rust
2
star
47

playfair-rs

Playfair cipher implemented in Rust
Rust
2
star
48

rust-arch-lto

Rust + ABS + LTO = ๐Ÿคฏ (PoC)
Shell
1
star
49

abstractapi-rs

Rust API bindings for the Abstract HTTP API
Rust
1
star
50

rust-tui-example

A very simple TUI program to demonstrate on Rust Munich Meetup #8
Rust
1
star
51

ytpls

[experimental] YouTube Playlist Synchronizer backed by yt-dl & git
Rust
1
star