Skip navigation.
 
mlRe: Re: Can't exec from a Cocoa app?
FROM : Tom Harrington
DATE : Thu Aug 24 18:48:09 2006

On 8/24/06, Uli Kusterer <witness.of.<email_removed>> wrote:
> Now, I'm wildly guessing here, but AFAIR exec and stuff like that
> basically create a copy of the current application (or am I mixing
> that up with fork?), where some things (like file descriptors to
> stdin and stdout) may still be shared. So maybe that also applies to
> a window server connection and that's why your app fails?


The short version is that fork creates a copy of the current process,
while exec replaces the current process with a new process binary.

It seems that while a straight exec doesn't work in this case, a fork
followed by an exec in the child process (and an exit in the parent)
is OK.  I still need to check and see that everything's working as
expected but at least I'm not stumbling over an undocumented error
condition anymore.

[And for those wondering why I'm not using something more Cocoaesque,
like using NSTask or asking NSWorkspace to help me out, it's because
this code is in a signal handler function.  Since signals are
delivered asynchronously it's generally not a good idea to use any
function calls not specifically documented as being safe for use in
that situation.]

--
Tom Harrington
<email_removed>
AIM: atomicbird1

Related mailsAuthorDate
mlCan't exec from a Cocoa app? Tom Harrington Aug 24, 00:46
mlRe: Can't exec from a Cocoa app? Andrew Farmer Aug 24, 01:14
mlRe: Re: Can't exec from a Cocoa app? Tom Harrington Aug 24, 01:47
mlRe: Can't exec from a Cocoa app? Uli Kusterer Aug 24, 11:56
mlRe: Can't exec from a Cocoa app? Andrew Farmer Aug 24, 17:58
mlRe: Re: Can't exec from a Cocoa app? Tom Harrington Aug 24, 18:48
mlRe: Can't exec from a Cocoa app? Douglas Davidson Aug 24, 19:08