Hello,
I am planning to implement a Global Launch Agent in my application which should be supported in the following modes, current logged in user,
while in Login Screen,
screen after user Logged out,
and screen after Mac is rebooted.
In all these cases, I want my Launch Agent to be running the executable so that I can support all my features in every case possible. Here is my launch agent plist file
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>agent name</string>
<key>LimitLoadToSessionType</key>
<array>
<string>LoginWindow</string>
<string>Aqua</string>
</array>
<key>ProgramArguments</key>
<array>
<string>path to executable</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>path to directory</string>
</dict>
</plist>
I am using LoginWindow, Aqua session types for LimitLoadToSessionType, so that I can load my executable during LoginScreen and Reboot screen(in these cases the executable will be loaded as a root process as there is no active user account).
All the possible user cases works fine expect one use case. Lets say I am logged into User1 account and launch agent loaded the executable under the User1 context and I clicked the "Login Window" from the Fast User Switching dialog box from top right corner, which will result in a user switch from the User1 to loginwindow context. In the loginwindow context the launch agent executable is loaded as the root process which is still fine for me.
But the problem comes when I log-in back into User1 account. When I logged into the User1 account I can still see the executable is loaded as root and I cannot unload it using the "sudo launchctl unload /path/to/plist/file" command from the Terminal, it throws "could not find specified service" error.
But when I run "sudo launchctl list", it lists the service.
Even "sudo launchctl stop service-name" also not much helpful.
So I will be left with 2 processes running at the same time, one process under root and another in User1 context. I am unable to handle have a single process for this user case. I appreciate any inputs here.
Thanks.
I am planning to implement a Global Launch Agent in my application which should be supported in the following modes, current logged in user,
while in Login Screen,
screen after user Logged out,
and screen after Mac is rebooted.
In all these cases, I want my Launch Agent to be running the executable so that I can support all my features in every case possible. Here is my launch agent plist file
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>agent name</string>
<key>LimitLoadToSessionType</key>
<array>
<string>LoginWindow</string>
<string>Aqua</string>
</array>
<key>ProgramArguments</key>
<array>
<string>path to executable</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>path to directory</string>
</dict>
</plist>
I am using LoginWindow, Aqua session types for LimitLoadToSessionType, so that I can load my executable during LoginScreen and Reboot screen(in these cases the executable will be loaded as a root process as there is no active user account).
All the possible user cases works fine expect one use case. Lets say I am logged into User1 account and launch agent loaded the executable under the User1 context and I clicked the "Login Window" from the Fast User Switching dialog box from top right corner, which will result in a user switch from the User1 to loginwindow context. In the loginwindow context the launch agent executable is loaded as the root process which is still fine for me.
But the problem comes when I log-in back into User1 account. When I logged into the User1 account I can still see the executable is loaded as root and I cannot unload it using the "sudo launchctl unload /path/to/plist/file" command from the Terminal, it throws "could not find specified service" error.
But when I run "sudo launchctl list", it lists the service.
Even "sudo launchctl stop service-name" also not much helpful.
So I will be left with 2 processes running at the same time, one process under root and another in User1 context. I am unable to handle have a single process for this user case. I appreciate any inputs here.
Thanks.