Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Launching an app from Carbon app (newbie question)



D'oh! Don't rely on the argv feature in LSOpenApplication. It's not working correctly in 10.4/Tiger.

You can either:

1. Send the arguments to the child process via a custom initial Apple Event (assuming to control the code in the child process).

2. Use the "double fork" (or better, double vfork) pattern to create an orphaned child process that won't terminate when its parent does. I couldn't find any Apple sample code for double fork, but you can Google "unix double fork" to see what the web has to offer.

-Chris

On Oct 18, 2005, at 9:26 PM, David A. Lyons wrote:

Starting in 10.4, LSOpenApplication (in LSOpen.h) allows you to launch an app and pass any combination of "argv" arguments, environment variables, and an AppleEvent.

After launching an app using Launch Services, your app can quit without causing the launched apps to quit along with it.

If you can't require Tiger, then I guess that doesn't help you.

(I'm sure there is a Unix-level solution, too...I just don't know what it is.)

Cheers,

--Dave


On Oct 16, 2005, at 7:01 PM, apple wrote:
I am in the process of porting an application from windows to Carbon. I have most of it working, but the original app would connect to a server, check to see if an update was available, if so, it would update itself. It updated itself by copying the application to a temporary directory, running the temporary copy, quitting the original one, then download the new app, save it in place of the original, call the updated app in a new process, and quit itself. When it is doing these executions of itself, it passes information between the various instances of itself by command line parameter. The original app used the windows CreateProcess execute the various instances of itself. I am trying to duplicate this behavior now (the application has to exist on both platforms, so I am basically trying to create a copy of the windows CreateProcess call). I coded it originally using the system( ) call, passing in the command line I needed followed by the & to make system return right!
away. If I verify each of these steps individually through the debugger's command line parameters, it seems to work, and if I run the application, it seems to update itself succesfully, but then quits in the middle of doing something. My guess is that the when the original process terminates, all the subsequent calls starting different process using system are killed, and so I can't complete the update. I tried using execve, but I always get a ENOTSUP returned from that, and can't figure out why. I looked into using Carbon's LaunchApplication call, but I don't see any way I can pass in command line parameters. Does anyone here have any suggestions as to what I could do to get this working?

_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Launching an app from Carbon app (newbie question) (From: "apple" <email@hidden>)
 >Re: Launching an app from Carbon app (newbie question) (From: "David A. Lyons" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.