Hi Piotr,

This sounds like a good use case for an XPC service. The service would ship in 
your app's bundle, and each instance of your app would have a private instance 
of the service that it talked to, and that instance would run with the same uid 
as your app. More here:

http://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/chapters/CreatingXPCServices.html
-damien

On 15 Jan, 2015, at 04:25, Piotr Panasewicz <piotr.panasew...@mac.com> wrote:
> Hello,
> 
> I would like to create a Launch Agent that would start on demand when my 
> bundle app requires it. I have it currently implemented like below which 
> monitors a specific path for existence of a file. This works ok for one user 
> logged in. If I there are more users logged via Fast User Switching the OS 
> tends to open the service for different user, not the one that’s currently 
> using my app. That’s because two users are now monitoring the same path and 
> the OS isn’t sure in which user’s context the service should run.
> 
> Also my bundle app has LSMultipleInstancesProhibited set to true, so it isn’t 
> allowed to run two instances at once. But if User A opens my app and there is 
> a User B logged in, the service may open for User B (even the file from the 
> plist was created by User A and User B hasn’t touched my app).
> 
> Therefore I need a solution that would allow my client app to open the 
> service for the same user it runs as. And if I close the app for User A, 
> switch to User B and start the client, the service would now open for User B.
> 
> Thanks,
> Peter
> 
> <?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>
>    <dict>
>        <key>PathState</key>
>        <dict>
>            <key>/Users/Shared/Company/Service.txt</key>
>            <true/>
>        </dict>
>    </dict>
>       <key>Label</key>
>       <string>com.company.service</string>
>       <key>Program</key>
>       <string>/Users/Shared/Company/Service</string>
>       <key>MachServices</key>
>       <dict>
>               <key>com.company.service</key>
>               <true/>
>       </dict>
> </dict>
> </plist>
> 
> _______________________________________________
> launchd-dev mailing list
> launchd-dev@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/launchd-dev

_______________________________________________
launchd-dev mailing list
launchd-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/launchd-dev

Reply via email to