FelixKratz / SketchyBarHelper

A header for C/C++ to directly communicate with SketchyBar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

question: why `exit(0)`when parent pid is 1?

PoiScript opened this issue · comments

Hello, I was trying to run my SketchyBarHelper as a launch agent. But i'm encountering a problem that the helper exits if its parent pid equal to 1 (which is launchd). I found out this behavior was introduced by this commit 73ee34d for handling kill signals, but I don't have any detail or context about this change. It's there any workaround to run the helper by launchd?

The idea is that the helper should never become an orphan, i.e. its ppid should not be 1 if it was not already initially. This ensures that the helper exits once the parent process does. Maybe its better to do a startup check for the ppid and only branch into the exit branch if the ppid has changed to 1.

@FelixKratz thank you for the explanation! I just moved the helper command to the bottom of sketchybarrc instead, so the helper can be launched at startup eventually. But I'm unsure if keeping a long-running job within sketchybarrc is recommended.