Skip to content

Check for running go2rtc has false positives #264

@irichter

Description

@irichter

The heuristic used by scan_proc_for_cmdline() (in src/video/go2rtc/go2rtc_process.c) to detect a running go2rtc process detects false positives. It detects any running process with "go2rtc" anywhere in the command line, including as an argument.

For example, running lightnvr 2>&1|tee /tmp/lightnvr.with.go2rtc.log will result in process with a cmdline that contains "go2rtc", but which is for tee instead. Another way to generate a false positive would be to run an application within a path that includes "go2rtc" as a substring (e.g.: /home/user/lightnvr-go2rtc-test-checkout/lightnvr).

Instead of scanning the entirety of cmdline, I'd recommend only scanning up to the first null (\0), and within that, and only scanning after the rightmost / to avoid substrings in directory names.

A more robust solution would be to do the equivalent of realpath(1) on the configured go2rtc binary path, as well as every /proc/*/exe symlink. If any resolved file names match exactly, then there's a running instance of the configured go2rtc. If one of the /proc/*/exe symlinks resolve to a path that ends in "/go2rtc", but that is not equivalent to the resolved configured go2rtc binary path, issue a warning that another go2rtc instance is likely running.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions