Re: fread multiple files
Re: fread multiple files
- Subject: Re: fread multiple files
- From: Steve Checkoway <email@hidden>
- Date: Fri, 25 Sep 2009 23:07:34 -0700
On Sep 25, 2009, at 4:24 PM, Terry Lambert wrote:
We don't support all of POSIX RT. The option set that that's in is
actially AIO, which is a subset of RT, and we don't se
_POSIX_ASYNCHRONOUS_IO in <unistd.h> because we don't support one of
the option flags to aio_fsync() in a POSIX compliant way.
So this seems like a case where relying on the version test macros in
unistd.h as a method of determining the usability of a function rather
than a link test is incorrect.
Just glancing through the list for the first time, I see _POSIX_SPAWN
is defined as -1 but I thought posix_spawn() was supported.
The following works for me, at least. It seems like the only sure way
to check if something will work is to write test code trying it since
one cannot rely on the version test macros nor on link tests. In
retrospect, this is obvious.
#include <spawn.h>
#include <sys/wait.h>
#include <stdio.h>
#include <errno.h>
extern char **environ;
int main( int argc, char *argv[] )
{
if( argc < 2 )
return 1;
pid_t pid;
int status;
int ret = posix_spawnp( &pid, argv[1], NULL, NULL, argv+1,
environ );
if( ret != 0 )
{
errno = ret; // lazy
perror( "posix_spawn" );
return 1;
}
ret = waitpid( pid, &status, 0 );
if( ret == -1 )
{
perror( "waitpid" );
return 2;
}
if( WIFEXITED(status) )
printf( "Exited normally with status %d\n",
WEXITSTATUS(status) );
else if( WIFSIGNALED(status) )
printf( "Terminated due to signal %d\n",
WTERMSIG(status) );
else
puts( "Something else" );
return 0;
}
--
Steve Checkoway
"Anyone who says that the solution is to educate the users
hasn't ever met an actual user." -- Bruce Schneier
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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