Skip to main content

Send CTRL-C event to a target console process WITHOUT causing KeyboardInterrput at the caller side.

Project description

Console CTRL

This simple package allows you to send CTRL-C event to a target console process WITHOUT causing KeyboardInterrput at the caller side.

The solution is based on posts shared on stackoverflow (see Reference for details).

Usage

Install with pip install console-ctrl

In you code:

import console_ctrl
import subprocess

# Start some command IN A SEPARATE CONSOLE
p = subprocess.Popen(['some_command'], creationflags=subprocess.CREATE_NEW_CONSOLE)
# Do something else

console_ctrl.send_ctrl_c(p.pid)

Note: the target process should be started with creationflags=subprocess.CREATE_NEW_CONSOLE.

Reference

Specially thanks to people shared solutions here:

More official docs:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

console-ctrl-0.1.0.tar.gz (2.3 kB view hashes)

Uploaded Source

Built Distribution

console_ctrl-0.1.0-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page