Understanding SIGRTMIN+24 in Systemd: User Instance Shutdown Signals Explained


3 views

When you encounter SIGRTMIN+24 in systemd logs from user sessions (like your Debian 8 VM output), it indicates a controlled termination request specifically for user-level systemd instances:

Received SIGRTMIN+24 from PID 22461 (kill)

This signal has distinct behavior compared to system-wide shutdowns:

  1. Scope-limited: Only affects the user's service manager (--user instances)
  2. Immediate action: Triggers direct termination without graceful shutdown sequence
  3. Common triggers: User session endings, manual kills, or session management tools

The log entries you observed:

Starting Shutdown.
Reached target Shutdown.
Starting Exit the Session...

Represent user session termination, not machine-level shutdown. This occurs when:

  • A user logs out via GUI/console
  • systemctl --user exit is executed
  • Session managers (like GDM/LightDM) end the session

For your case with repeated shutdown sequences, check these components:

1. Session Tracking

journalctl _UID=$(id -u $USER) -b | grep -E 'Starting Shutdown|SIGRTMIN'

2. Process Tree Analysis

pstree -T -p $(pgrep -u $USER systemd)

3. Common Culprits

  • Broken .service files: Check user units under ~/.config/systemd/user/
  • DBus issues: Verify with dbus-monitor --session
  • Resource limits: Inspect via systemd-analyze user-unit-paths

For advanced debugging, you can trap the signal:

# Python example
import signal
import sys

def handler(signum, frame):
    print(f"Received signal {signum}")
    sys.exit(0)

signal.signal(signal.SIGRTMIN+24, handler)

When examining systemd logs on Debian systems, you might encounter entries like:

Apr 28 23:02:09 foo systemd[22305]: Received SIGRTMIN+24 from PID 22461 (kill).

This signal has specific behavior in systemd's architecture:

  • User Instance Specific: Only affects user-level systemd instances (--user)
  • Immediate Termination: Forces the manager process to exit without cleanup
  • Signal Range: Part of the real-time signals (SIGRTMIN to SIGRTMAX)

The log sequence you're seeing indicates a controlled user session termination:

Starting Shutdown → Reached target Shutdown → Starting Exit the Session → SIGRTMIN+24

This typically occurs during:

  • User logout procedures
  • Session timeout events
  • Manual termination via systemctl --user commands

The key distinction lies in systemd's architecture layers:

# System-level services remain unaffected because:
1. User instances run in isolated scope
2. SIGRTMIN+24 only impacts the --user tree
3. System services run under PID 1 (system instance)

To investigate why these signals are appearing frequently:

# Check user session activity
journalctl _UID=$(id -u username) -b

# Verify active user units
systemctl --user list-units

# Trace signal origins
strace -p $(pgrep -u $USER systemd) -e signal=SIGRTMIN+24

From Debian system diagnostics, frequent triggers include:

  1. Automated session cleanup scripts
  2. Display manager logout sequences
  3. Resource-constrained environments forcing session termination

For systems where this behavior is undesirable:

# Adjust user session linger
loginctl enable-linger username

# Modify StopWhenUnneeded behavior
systemctl --user edit --full
[Service]
StopWhenUnneeded=no

When developing systemd-aware applications:

# Example Python signal handler
import signal
import systemd.daemon

def handle_rt24(signum, frame):
    systemd.daemon.notify('STOPPING=1')
    # Custom cleanup logic here
    
signal.signal(signal.SIGRTMIN+24, handle_rt24)