Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Application running in wrong user screen when started using launchagent

Application running in wrong user screen when started using launchagent
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2013
Status: Offline
Reply With Quote
Jun 12, 2013, 08:44 AM
 
I have a LaunchAgent with starts my app when loaded. This app will run on per user mode. When there are multiple users logged in using fast user switch, the app should run for each user.

So the binary loading the LaunchAgent is running as root. For loading I am giving the command as

launchctl bsexec 64 chroot -u <username> / launchctl load -w -F -s Aqua /Library/LaunchAgents/<name_launchagent>.plist
The number 64 is the PID of loginwindow.
This command is executed for each user logged in with PID of loginwindow for each user.
But all this app are appearing on the window of the currently logged in user. The app is a menubar app, when launchagent is loaded for each user, current active user's menubar fills with multiple icons of app loaded for each user. In activity monitor I could see that the user name for each app is correctly specified.

Can some help me on this. Why is the app for other users shown on the currently logged in screen?!.
Is there any other way to load app for all the users currently logged in to the system?

Thanks
Vipin Johney
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
Jun 12, 2013, 10:26 AM
 
Not an expert of launchctl, but...why are you using chroot? That command will only change the perceived root directory of a process. Is that what you're trying to do?
The new Mac Pro has up to 30 MB of cache inside the processor itself. That's more than the HD in my first Mac. Somehow I'm still running out of space.
     
Fresh-Faced Recruit
Join Date: Jun 2013
Status: Offline
Reply With Quote
Jun 14, 2013, 01:57 AM
 
Yes that's what I was trying .
The binary from which the command is executed is running under root and I want to load the LaunchAgent as users logged in to the machine, that's why I am using chroot command.
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
Jun 14, 2013, 05:47 AM
 
That's not what chroot does. chroot changes the root directory as seen by the program, not the user that runs a program - basically, it make the program unable to move "up" in the directory tree. Root can switch to any other user with the command "su" and execute a single command as another user with "sudo". Check out those commands.

Again, barely ever used launchctl, but generally you can't just chain commands like that by typing them after each other. If you want one command to wait for the previous to execute first, chain them with &&.
The new Mac Pro has up to 30 MB of cache inside the processor itself. That's more than the HD in my first Mac. Somehow I'm still running out of space.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -4. The time now is 04:09 PM.
All contents of these forums © 1995-2014 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2014, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2