diff --git a/lidar_pipeline/cli.py b/lidar_pipeline/cli.py index 672ec85..87fb1bb 100644 --- a/lidar_pipeline/cli.py +++ b/lidar_pipeline/cli.py @@ -5,6 +5,8 @@ Handles argument parsing, logging configuration, and entry point. import argparse import logging +import os +import signal import sys from .pipeline import LidarArchaeoPipeline @@ -145,6 +147,12 @@ Exemples: logger.info("Pipeline LiDAR Archéologique") logger.info("=" * 60) + # Kill orphan PDAL processes on interrupt or termination + signal.signal(signal.SIGINT, _kill_orphan_pdal) + signal.signal(signal.SIGTERM, _kill_orphan_pdal) + import atexit + atexit.register(_kill_orphan_pdal) + log_gpu_status() try: @@ -191,4 +199,21 @@ Exemples: pipeline.process_all() except Exception as e: logger.error(f"Erreur fatale: {e}", exc_info=True) - sys.exit(1) \ No newline at end of file + sys.exit(1) + + +def _kill_orphan_pdal(signum=None, frame=None): + """Kill orphan PDAL processes on interrupt or exit.""" + import subprocess + try: + subprocess.run(["pkill", "-f", "pdal"], capture_output=True, timeout=5) + except Exception: + pass + if signum is not None: + logger.info("Interruption — nettoyage des processus PDAL") + sys.exit(130) + + +def main(): + """Entry point for the LiDAR archaeological pipeline.""" + parser = argparse.ArgumentParser( \ No newline at end of file