fork/exec a child process from a bundle app

Hello,

I current have two command line C applications, processA and processB.
All processA does is fork/exec processB.
This works as expected from the command line, and if I look in Activity Monitor
I can see them named under "Process Name" as processA and processB.

This simplicity all seems to fly out the window when you introduce a Bundle, and I can't figure out what is going on.

I make simple Bundle called processA.app.
It contains an Info.plist, a MacOS folder with processA and processB inside, and a PkgInfo file, all inside a Contents folder.
The Info.plist is correctly configured to point to processA.

When I run the bundle, both apps appear in the Activity Monitor under the name "processA". Why? Its like processB is still associated with the bundle for some reason and I don't want it to be. I even tried moving processB outside the bundle and executing it from there but its still the same.

Any ideas on this?

One final thing I noticed .. the C sleep() function seems to just not work
when used in a bundled app. Any reason?

Much thanks,
David

MacBook Pro, Mac OS X (10.5.7)

Posted on May 20, 2009 4:54 PM

Reply
2 replies

May 21, 2009 7:00 AM in response to dwibbitson

I can't duplicate your problem. Both the fork/exec and sleep appear to work properly from a bundle and the sleep function works.

My first process


#include <unistd.h>
#include <stdio.h>
int main()
{
pid_t p;
p = fork();
if (p) {
execl("/Users/ericmeyers/meh2","/Users/ericmeyers/meh2",(char*) 0);
}
printf("process 1 sleeping ");
sleep(10);
return 0;
}


My second process


#include <unistd.h>
#include <stdio.h>
int main()
{
printf("%s","process 2 sleeping ");
sleep(10);
return 0;
}


You're being fooled by Activity Monitor. I think it shows the Process Group as the name. If you run top in a terminal then launch your bundle you'll see 2 processes with different names.

Eric

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

fork/exec a child process from a bundle app

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.