• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Fun with fork/exec in the XCode debugger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fun with fork/exec in the XCode debugger


  • Subject: Re: Fun with fork/exec in the XCode debugger
  • From: Chris Friesen <email@hidden>
  • Date: Tue, 14 Feb 2006 13:54:24 -0800

You might start by comparing the environment settings when debugging in Xcode against running from Finder. While paused in the debugger in Xcode you can enter 'show env' in the debugger console.

-ChrisF

On Feb 14, 2006, at 1:33 PM, Timothy Standing wrote:

I have several functions in a statically linked library which use fork/exec to call some command line tool to perform some work. They use fork/exec and then call waitpid, WIFEXITED and WEXITSTATUS to wait for the child process to end and then retrieve its status. These calls all work fine when I run the debug build of my product by launching it in the Finder. When I run it from the XCode 2.2 debugger, however, I get results from WIFEXITED and WEXITSTATUS which don't make any sense.

I have searched the mailing list archives and the two POSIX books I have on hand for an explanation, but have found none. So it is time to write to the list and ask the gurus on the list.

	As an example, when I execute the following routine:

bool RemoveDirectory(const char * directoryPathname)
{
	bool result = true;
	pid_t pid;
	int status;

	pid = fork();

switch (pid)
{
case 0:
execl("/bin/rm", "rm", "-rf", directoryPathname, 0);
break;

case -1:
result = false;
break;

default:
// Make sure the folder was correctly deleted.
waitpid(pid, &status, 0);

printf("RemoveDirectory; status = 0xx, WIFEXITED(status) = 0x% 04x, WEXITSTATUS(status) = 0xx\n",
status, WIFEXITED(status), WEXITSTATUS(status));

result = (WIFEXITED(status) && (WEXITSTATUS(status) == EXIT_SUCCESS));
}

return result;
}


it produces the output I expect in console.log when run from the Finder (or in Run Log window when run from inside XCode 2.2):

RemoveDirectory; status = 0x0000, WIFEXITED(status) = 0x0001, WEXITSTATUS(status) = 0x0000


The output in the Debugger Console window when run in XCode 2.2 using the debugger seems totally incorrect however:


RemoveDirectory; status = 0x346990, WIFEXITED(status) = 0x0000, WEXITSTATUS(status) = 0x3469


Note: This routine removes the directory correctly whether I run it from the Finder or from the XCode debugger, it is only the value of status which seems to be incorrect. (I am not using zerolink and have not performed a build between the any of the attempts at running the executable.)



So the questions are:

	- Does anyone have an explanation?

	- Is there a work around?

	- Am I doing something wrong?


Thanks in advance,

	Tim Standing
	SoftRAID, LLC

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Fun with fork/exec in the XCode debugger (From: Timothy Standing <email@hidden>)

  • Prev by Date: Fun with fork/exec in the XCode debugger
  • Next by Date: Re: Preprocessing .nib files?
  • Previous by thread: Fun with fork/exec in the XCode debugger
  • Next by thread: Re: Fun with fork/exec in the XCode debugger
  • Index(es):
    • Date
    • Thread