Metadata-Version: 2.4
Name: pexit
Version: 0.1.0
Summary: A CLI tool to exit any process with arbitrary exit code
Author-email: John Ao <johnao73thu@gmail.com>
License: Copyright (c) 2025 John Ao
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project-URL: Homepage, https://github.com/John-Ao/pexit
Keywords: exit,kill,process
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: C
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.0
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# pexit

> This is a CLI tool to exit any process with arbitrary exit code.

Instead of killing a process, do you ever want to "exit" it? `pexit` comes to the rescue!

With some prerequisites (see below), you can force any process to exit, even with your specified exit code!

## Why would you want to use `pexit`?

* For fun.
* In the case of running a pipelined job `foo && bar`, simply killing `foo` will cause it to exit with error and `bar` is not executed. Using `pexit`, however, can make `foo` exit with success so that `bar` continues to be executed.

## Install
```
pip install pexit
```

## Usage
```
pexit <pid> [<exit_code>]
# The default value for <exit_code> is 0 (meaning success)
```

## Limitations
* `pexit` relies on the system call `ptrace`, which does not exit in some systems (like Windows).
* To be able to `ptrace` any process, you may need root privilege (`sudo pexit ...`) or allow this in system setting (`sudo sysctl kernel.yama.ptrace_scope=0`).

## Acknowledgements
This project refers to the following sources:
* A great example showcasing how to use `ptrace` to run `printf`: https://github.com/eklitzke/ptrace-call-userspace/blob/master/call_fprintf.c
