Git Product home page Git Product logo

zps's Introduction

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 based on the arguments provided (by default using SIGTERM). 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.

Table of Contents

Installation

Arch Linux

pacman -S zps

Alpine Linux

apk add 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

With manual compilation, you might want to also pass -DNDEBUG to disable runtime assertions.

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:
  -v, --version        show version
  -h, --help           show help
  -a, --all            list all user-space processes
  -r, --reap           reap zombie processes
  -s, --signal   <sig> signal to be used on zombie parents
  -p, --prompt         show prompt for selecting processes
  -q, --quiet          reap in quiet mode
  -n, --no-color       disable color output

zps -r/--reap

zps -r

zps -s/--signal

zps -s

zps -p/--prompt

zps -p

zps -q/--quiet

zps -q

zps -n/--no-color

zps -n

License

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

Copyright

Copyright © 2019-2024, Orhun Parmaksız

zps's People

Contributors

cycatz avatar devtae avatar mforthewin avatar orhun avatar xfgusta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zps's Issues

exited processes shown as zombies

I am on Arch Linux and using alacritty as my terminal.

when i executed "zps -l" , it is listing all exited processes from terminal as zombies. If such a process is killed using "zps -p", terminal and tmux sessions are closed.

A screenshot of list of processes shown as zombies :

screenshot_20210121111543

Gentoo ebuild request

I would love to use this on Gentoo. I can build it manually, yes, but adding it to gentoo would be nice too. It can be then submitted to the official repo or one of the overlays.

Check Korean README for mistranslations introduced in new release

As new CLI options are to be introduced in the upcoming release of zps, I tried my best to adapt the existing translation to the new behavior and flags, using a combination of ChatGPT, DeepL and Google Translate to verify if the correct meanings are conveyed.

Thus, it would be great if someone could verify (at least) the changes made in #17 and fix any mistranslations.

Potential extension to the behavior of the `cmdline`/`COMMAND` column

One idea not addressed in #17 was that the truncation of the cmdline contents in the COMMAND column of zps's output maybe should be adapted to allow longer output depending on the number of available terminal columns. An example of this would be ps, which attempts to display the contents up to the line limit of the interactive terminal, unless stdout is piped to a different program's stdin – like grep, for example –, in which case the whole cmdline is displayed.

Introducing this functionality would still have one issue, however: Users looking for a specific substring in the interactive output of zps would not find every match that grep-ing would show, due to differences in the maximum line lengths and occurring truncation.
Thus, it might actually be desirable to actually limit the lengths in any case, so users are required to check the contents through alternative sources/programs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.