Score:0

OSX How to prevent user unload a daemon?

yt flag

I'm working in a task to keep Mac application is always alive. I'm success to create a plist file to make app respawn when user force quite app from Dock or kill process from Activity Monitor Here's my plist file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.mydaemon</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/MyApp.app/Contents/MacOS/MyApp</string>
        <string>-runMode</string>
        <string>ifneeded</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/tmp/LaunchAgentErr.stderr</string>
    <key>StandardOutPath</key>
    <string>/tmp/LaunchAgentOut.stdout</string>
    <key>StartInterval</key>
    <integer>1</integer>
</dict>
</plist>

However user still unload my daemon to stop my app by using:

launchctl bootout gui/501 Library/LaunchAgents/com.mydaemon.plist 

My question is how to prevent user unload my daemon by using above command? Or is there any solution to trigger load automatically when daemon is unloaded? Any help will be appreciated!

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.