Skip to content

Singleton lock: refuse to start when another trafficcop is running #36

Description

@mack42

Live AiFw appliance shows 6 trafficcop processes running from 5 distinct start times — orphans accumulating from buggy rc.d, but defense-in-depth requires the binary itself to refuse a second invocation regardless of how it was launched.

Fix: copy the single_instance helper from AiFw (aifw-common/src/single_instance.rs — fcntl F_SETLK F_WRLCK on /var/run/trafficcop.lock) and call acquire("trafficcop") at the top of main. On AlreadyRunning(pid), print error and exit 1.

Tracking spec (in AiFw repo): docs/superpowers/specs/2026-04-26-process-hardening-and-ids-extraction-design.md

Acceptance: running trafficcop while one is already running prints trafficcop: another instance is already running (pid X) and exits 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Planned

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions