SIGKILL used instead of SIGTERM when force-killing backup process #5

Open
opened 2025-11-15 03:44:09 +00:00 by snegov · 0 comments
Owner

SIGKILL used instead of SIGTERM when force-killing backup process

Priority: High
Component: backup.py
Type: Bug

Description

When the --force flag is used and a previous backup is still running, the code sends SIGKILL to terminate it. This doesn't allow the previous process to clean up resources, release locks, or remove incomplete backups.

Location

curateipsum/backup.py:128

Current Code

os.kill(pid, signal.SIGKILL)

Problem

SIGKILL (signal 9) cannot be caught or ignored by the process, preventing graceful cleanup. This could leave:

  • Incomplete backup directories
  • Unclosed file descriptors
  • Corrupted backup metadata

Proposed Solution

Send SIGTERM first, wait briefly, then escalate to SIGKILL if needed:

_lg.warning("Sending SIGTERM to process %d", pid)
os.kill(pid, signal.SIGTERM)
time.sleep(5)
if _pid_exists(pid):
    _lg.warning("Process %d didn't terminate, sending SIGKILL", pid)
    os.kill(pid, signal.SIGKILL)

Impact

High - Current behavior can leave backup directory in inconsistent state.

# SIGKILL used instead of SIGTERM when force-killing backup process **Priority:** High **Component:** backup.py **Type:** Bug ## Description When the `--force` flag is used and a previous backup is still running, the code sends `SIGKILL` to terminate it. This doesn't allow the previous process to clean up resources, release locks, or remove incomplete backups. ## Location `curateipsum/backup.py:128` ## Current Code ```python os.kill(pid, signal.SIGKILL) ``` ## Problem `SIGKILL` (signal 9) cannot be caught or ignored by the process, preventing graceful cleanup. This could leave: - Incomplete backup directories - Unclosed file descriptors - Corrupted backup metadata ## Proposed Solution Send `SIGTERM` first, wait briefly, then escalate to `SIGKILL` if needed: ```python _lg.warning("Sending SIGTERM to process %d", pid) os.kill(pid, signal.SIGTERM) time.sleep(5) if _pid_exists(pid): _lg.warning("Process %d didn't terminate, sending SIGKILL", pid) os.kill(pid, signal.SIGKILL) ``` ## Impact **High** - Current behavior can leave backup directory in inconsistent state.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: snegov/cura-te-ipsum#5
No description provided.