[launchd-dev] Problem with launchd starting user defined launchagent service in root user login

Thomas Clement tclementdev at gmail.com
Thu Dec 22 01:34:37 PST 2011


The "-u" flag only works for the root user.
Maybe you can have a condition in your shell script and use the "-u root" option only when appropriate.

Thomas

On Dec 22, 2011, at 10:29 AM, Nandini Vijayashankar wrote:

> Hi,
>  
> Thanks a lot...
> Its working from root user login.
> If I use the same command from non-root user login, iam getting error.
> I used:
> launchctl -u <username> unload /System/Library/LaunchAgents/<plistfile>
> Unknown user:<username>
>  
> I  want to use a generic command from my shell script to unload the plist file which is applicable for both root and non-root user login.
> Is it possible?
>  
> Thanks
>  
> >>> Thomas Clement <tclementdev at gmail.com> 12/22/2011 2:40 PM >>>
> Hi,
> 
> You should try:
> launchctl -u root unload /System/Library/LaunchAgents/<plistfile>
> 
> Thomas
> 
> On Dec 22, 2011, at 6:00 AM, Nandini Vijayashankar wrote:
> 
>> Hi,
>>  
>> I want to know how does launchd start the user defined launchagents service when a "root" user logs in to the system.
>>  
>> Iam using Mac 10.6
>>  
>> I have a launchdaemon and launchagent present in /System/Library/LaunchDaemons and /System/Library/LaunchAgents.
>>  
>> When I login with a non-root user, my launchagent service is started as that logged in user.
>> I can unload this service using "launchctl unload /System/Library/LaunchAgents/<plistfile>"
>>  
>> If I login as root user,my launchagent  service is started and working fine.But its not started as logged in user ie., root.
>> If I try to unload through "launchctl unload /System/Library/LaunchAgents/<plistfile>" I get error:
>> launchctl : Error unloading <id>
>>  
>> This is because the service is not launched as root user.
>>  
>> Above scenarios are working fine in Mac 10.5 as root and non-root user.
>>  
>> When i see my launchagent service in Activity monitor, the parent process is the per-user launchd instance.
>> The parent process of this launchd is system launchd with pid 1.
>>  
>> I have tried to list the service using various commands:
>> launchctl list
>> launchctl bslist
>> sudo launchctl list
>>  
>> All these are not showing my launchagent service.Is there any special way, launchd launches launchagents service when a root user logs in Mac 10.6?
>>  
>> How can i unload my launchagent service when the root user logs in?
>>  
>>  
>>  
>>  
>> _______________________________________________
>> launchd-dev mailing list
>> launchd-dev at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-dev/attachments/20111222/78bd9a7c/attachment.html>


More information about the launchd-dev mailing list