Skip to content

macOS LaunchAgent should set ProcessType=Background to prevent termination during session transitions #34089

@joemcurry

Description

@joemcurry

Bug Description

On macOS, the OpenClaw gateway service gets terminated (SIGTERM) when the user session transitions to the login screen, even when sleep is disabled. The LaunchAgent generated by openclaw gateway install is missing the ProcessType=Background key, causing macOS to kill the process for "efficiency" reasons.

Observed Behavior

  • Gateway receives SIGTERM when screen goes to login screen (not sleep)
  • launchctl print gui/$UID/ai.openclaw.gateway shows immediate reason = inefficient
  • Gateway restarts via KeepAlive, but this causes a service interruption

Root Cause

macOS applies aggressive power management to user processes. Without ProcessType=Background, macOS treats the node process as a foreground application and may terminate it during session transitions when it determines the process is using resources "inefficiently."

Fix

Add <key>ProcessType</key><string>Background</string> to the LaunchAgent plist template. This tells macOS that this is a legitimate background daemon that should not be killed for efficiency reasons.

Current plist (missing):

<key>Umask</key>
<integer>63</integer>
<key>ProgramArguments</key>

Fixed plist:

<key>Umask</key>
<integer>63</integer>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

Environment

  • macOS Sequoia (15.x)
  • OpenClaw v2026.3.2
  • Installed via openclaw gateway install

Workaround

Manually add ProcessType=Background to the plist and reload:

# Backup
cp ~/Library/LaunchAgents/ai.openclaw.gateway.plist ~/Library/LaunchAgents/ai.openclaw.gateway.plist.backup

# Edit plist to add ProcessType=Background
# Then reload
launchctl bootout gui/$(id -u)/ai.openclaw.gateway
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/ai.openclaw.gateway.plist

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions