spawn()

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,

Matt.

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/

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,

spawn() is the most complicated of the spawn*() family to use, with lots
of different options and choices. If you don’t need that much control,
one of the others might be easier to use.

And, with that much complexity in the argument list, diagnosing a problem
from an errno is nearly impossible, to even start we’d need to see the
context it is used in, that is what arguments are passed and how they
were filled in.

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com

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:


char **szArguments;
struct inheritance inInheritance;

iReceiveChannel = ChannelCreate(0);
strcpy(szArguments[0], “Matt_ProcessesClient”);
sprintf(szArguments[1], “%d”, iReceiveChannel);

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.

Matt.

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

David Gibbs wrote:

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

Thanks David, I was able to use spawnl(…) to start another process.
However, I would like to try and get the original spawn(…) to work, and
I believe it has to do with not initializing the inheritance structure. I
was told that it would be set to a default one when created, however I’m
pretty sure this isn’t the case. Do you know how to fill-in this
inheritance structure (or any sample code, that would be much easier) ?
Thanks again,

Matt.

Mathew Asselin <m2asselin@yahoo.com> wrote:

Thanks David, I was able to use spawnl(…) to start another process.
However, I would like to try and get the original spawn(…) to work, and
I believe it has to do with not initializing the inheritance structure. I
was told that it would be set to a default one when created, however I’m
pretty sure this isn’t the case. Do you know how to fill-in this
inheritance structure (or any sample code, that would be much easier) ?
Thanks again,

The documentation for the spawn() function tells what needs to be
filled in for each parameter, and also talks about setting up the
inherit structure, too.

To my knowledge, there isn’t a “default” one created for when you
call spawn() – but if you call the other spawn*() functions, they
will fill in an inheritance structure along the way, and eventually
call spawn() with all the arguments set appropriately.

Note, before calling spawn() you will, also, have to figure out
the full path to your executable, and that is probably another
one of the errors you hit. (You just passed in an executable
name, spawn() will NOT search for this executable, it won’t
check the PATH for it, you have to do it. That is another one
of the conveniences that the spawn*() functions do for you.)

spawn() is the low-level, you should know exactly what you are
doing, function for creating another process.

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com

David Gibbs wrote:

Mathew Asselin <> m2asselin@yahoo.com> > wrote:

Thanks David, I was able to use spawnl(…) to start another process.
However, I would like to try and get the original spawn(…) to work, and
I believe it has to do with not initializing the inheritance structure. I
was told that it would be set to a default one when created, however I’m
pretty sure this isn’t the case. Do you know how to fill-in this
inheritance structure (or any sample code, that would be much easier) ?
Thanks again,

The documentation for the spawn() function tells what needs to be
filled in for each parameter, and also talks about setting up the
inherit structure, too.

To my knowledge, there isn’t a “default” one created for when you
call spawn() – but if you call the other spawn*() functions, they
will fill in an inheritance structure along the way, and eventually
call spawn() with all the arguments set appropriately.

Note, before calling spawn() you will, also, have to figure out
the full path to your executable, and that is probably another
one of the errors you hit. (You just passed in an executable
name, spawn() will NOT search for this executable, it won’t
check the PATH for it, you have to do it. That is another one
of the conveniences that the spawn*() functions do for you.)

spawn() is the low-level, you should know exactly what you are
doing, function for creating another process.

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com

Thanks David, I got the spawnl() to work, and I think I’ll give it another
hour on spawn(), just to see if I can understand my mistakes. Thanks.
Matt.