site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Sep 25, 2009, at 4:24 PM, Terry Lambert wrote: #include <spawn.h> #include <sys/wait.h> #include <stdio.h> #include <errno.h> extern char **environ; -- Steve Checkoway "Anyone who says that the solution is to educate the users hasn't ever met an actual user." -- Bruce Schneier _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com 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. 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; } smime.p7s