RE: Problem with system()
RE: Problem with system()
- Subject: RE: Problem with system()
- From: Norm Green <email@hidden>
- Date: Fri, 6 Jul 2007 11:44:20 -0700
Title: RE: Problem with system()
>You are not having a good time with file descriptors, are you?
Right, but only on Darwin ;-) The code in question runs fine on Solaris, HPUX, AIX and Linux.
>Make sure you actually aren't using lots of descriptors (as Terry
>suggested).
I'm not.
>The probability is high that it's your code, not Mac OS X, that is at >fault.
That may be, but how can I determine what's wrong?
Norm
-----Original Message-----
From: Justin C. Walker [mailto:email@hidden]
Sent: Friday, July 06, 2007 11:27 AM
To: email@hidden list
Subject: Re: Problem with system()
On Jul 6, 2007, at 11:07 , Norm Green wrote:
> I cannot get the system command to work from within my program and
> I see a
> strange error message printed to stdout/stderr when I try.
>
> If I run:
>
> int rc = system("date >/usr/tmp/tmp.kPCvVa");
>
> If fails with rc == 256 and errno == 0 and prints this to stderr:
>
> sh: line 1: 1: Bad file descriptor
You are not having a good time with file descriptors, are you?
> To make it even more weird: if I start the process under gdb and
> run the
> code, it works perfectly!
One possibility is "good garbage vs. bad garbage". The environment
with gdb will be different than without (gdb and the shell both fork
() and then exec() the program in question, but there will be
different garbage lying around in memory, in the two cases).
Make sure you actually aren't using lots of descriptors (as Terry
suggested). The probability is high that it's your code, not Mac OS
X, that is at fault. It's no guarantee either way, of course, but
without something more concrete to go on, it will be hard to diagnose.
None of your problems show up for me in simple test cases, so
whatever else is going on, it's either your code causing the problem,
or your code exacerbating a problem in the system that hasn't been
seen before.
A few random thoughts: Do you have more than one Mac OS X system to
try this on? Have you replaced/added memory in the system you are
using? Do the the system or console logs show anything that seems
off-beat?
Justin
--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
-----------
I'm beginning to like the cut of his jibberish.
-----------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev 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.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden