Re: Forcing an application into the foreground
Re: Forcing an application into the foreground
- Subject: Re: Forcing an application into the foreground
- From: John Stiles <email@hidden>
- Date: Wed, 2 Mar 2005 14:34:54 -0800
On Mar 2, 2005, at 2:34 PM, Douglas Davidson wrote:
On 2005-03-02 14:08:58 -0800 John Stiles <email@hidden> wrote:
It is illegal to launch a Cocoa/Carbon app via a BSD call like fork/exec. You will get goofy unspecified behavior, and the fact that it's not coming to the foreground is in fact one of those symptoms. (Another symptom I've seen is that the menubar sometimes fails to draw.)
This simply isn't true. You can launch an application via fork/exec--for example, you can run an application from an interactive shell by executing its main executable. However, you must make sure that the exec specifies sufficient information for the application to locate its executable using argv[0]. The easiest way to ensure this is by passing a full correct absolute path for your argv[0], for example by duplicating the first argument of execl().
Where were you when this came up on CarbonDev last month? ;) ;)
This is good info to have. I didn't know about argv[0].
However, in general, if you launch an app on the command line without supplying an argv[0], there
are all sorts of difficult-to-predict bugs that can result.
You need to use NSWorkspace or Launch Services to launch your app.
It certainly is easier to use NSWorkspace or Launch Services to launch an application, and it will probably give less trouble in general. However, there are certain situations in which one wishes for example to specify arguments, or environment variables, for which a fork/exec may be more suitable.
Or if you're a daemon :)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden