Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

SysProc

SysProc class.

Wrapper of psutil.Process class. This class that only exposes necessary functionalities to easily manage shell processes.

Functions
__init__

Initialize self. See help(type(self)) for accurate signature.

process : psutil.Process | None
use_process_group : bool - False
get_all_children

Return all the chlidren of process recursively.

Return type : list
get_process
Return type : Process
is_alive
Return type : bool
is_zombie
Return type : bool
kill
kill_with_children

Kill the process and all its children.

If the process was started with a process group (start_new_session=True), sends SIGTERM to the entire process group first for graceful shutdown, waits briefly, then sends SIGKILL to any survivors. Otherwise, falls back to killing each child individually.

stats

Get process statistics

Return type : dict
wait

Wait for a process PID to terminate

timeout : Any
popen @classmethod
cmd : Any
Return type : SysProc
from_pid @staticmethod
pid : Any
Return type : SysProc
kill_process_on_port @staticmethod

Find any process with a LISTEN socket on port and kill its entire process group.

Killing the process group (SIGKILL via killpg) takes down the listener plus its supervisor and siblings atomically — necessary for runners like Reflex where the listener's parent would otherwise respawn a replacement between our kill and the next bind attempt.

Returns the list of PIDs that were targeted (may be empty). If the OS denies access to enumerate sockets, logs a warning and returns [].

port : int
Return type : list
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.