Mathew Asselin <m2asselin@yahoo.com> wrote:
Chris McKillop wrote:
Mathew Asselin <> m2asselin@yahoo.com> > wrote:
Hello,
I am trying to start a child process from a parent process with the
spawn() function. However, this function does not work, and returns an
errno: NOT SUPPORTED. Has anyone experienced this type of problem before,
or know of why I am getting it? Thanks in advance,
Best thing to do is post some test code that shows the failure.
chris
–
Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/
Here is the code that was used to generate that error:
There are a few places this is wrong.
From the parameters you are setting, it looks like you would do far
better with the (simpler) call to spawnl() as follows:
spawnl( P_NOWAIT, “Matt_ProcessesClient”, “Matt_ProcessClient”, “”,
NULL );
char **szArguments;
The function takes a char *argv[], not a char **argv. There are
some places where these syntaxes can be used interchangeably in the
C language, but they are NOT the same thing. The first, that this
function takes, is an array of pointers to char – the second is a
pointer to a pointer to char.
struct inheritance inInheritance;
It looks like you pass this unitialized in to spawn(), this structure
defines a lot of the behaviour of the spawn() function. I don’t know
if you’ve declared this on the stack (local variable) or as a global,
but especially if on the stack, you’re passing in essentially random
data, and that will give unpredictable and usually wrong requests.
iReceiveChannel = ChannelCreate(0);
strcpy(szArguments[0], “Matt_ProcessesClient”);
sprintf(szArguments[1], “%d”, iReceiveChannel);
Were did you allocate memory for those pointers?
Also, the argument list must be null terminated, that is you need:
szArguments[2] = NULL;
Or this is an invalid argument list.
pidClientIdentifier = spawn(“Matt_ProcessesClent”,0,NULL,&inInheritance,
szArguments, NULL);
if ( pidClientIdentifier == -1)
printf("[Server] Failed to launch client: %s\n", strerror(errno));
OUTPUT: “[Server] Failed to launch client: Not supported”
I was wondering if it had something to do with the inheritance structure,
or since I have an educational version of QNX. Thanks again for your
help.
Could be any number of the errors above. (It is nothing to do with having
an eductational version.)
-David
Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com