shakthi b
08/30/2011 7:29 AM
post88480
|
//code
/*#include <spawn.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main(int argc,char **argv)
{
char *args[]={"child",NULL};
int i;
pid_t pid;
struct inheritance inherit;
for (i=0;i<3;i++)
{
inherit.flags |= SPAWN_EXEC;
if((pid=spawn("sharedmemorymodel",0,NULL,&inherit,args,environ))==-1)
perror("spawn failed");
else
printf("the spawn id %d",pid);
}
return 0;
}
*/
i have tried this code in qnx momentics and i used vmware to run qnx rtos.. while executing this code i got error like
spawn:not supported.. couldn't find out what is the problem.. whether running in windows, executing qnx exe is not
supportable? or some other problem. pls help me asap
thanks in advance,
shakthi
|
|
|
Peter Weber
|
Re: spawn system call error
|
Peter Weber
08/30/2011 7:34 AM
post88481
|
Re: spawn system call error
how about a memset(&inherit, 0, sizeof(struct inherit)) ? :-)
> //code
>
> /*#include <spawn.h>
> #include<stdio.h>
> #include<stdlib.h>
> #include<unistd.h>
> int main(int argc,char **argv)
> {
> char *args[]={"child",NULL};
> int i;
> pid_t pid;
> struct inheritance inherit;
> for (i=0;i<3;i++)
> {
> inherit.flags |= SPAWN_EXEC;
> if((pid=spawn("sharedmemorymodel",0,NULL,&inherit,args,environ))==-1)
> perror("spawn failed");
> else
> printf("the spawn id %d",pid);
> }
> return 0;
> }
> */
>
> i have tried this code in qnx momentics and i used vmware to run qnx rtos..
> while executing this code i got error like spawn:not supported.. couldn't find
> out what is the problem.. whether running in windows, executing qnx exe is
> not supportable? or some other problem. pls help me asap
>
> thanks in advance,
> shakthi
|
|
|
Peter Weber
|
Re: spawn system call error
|
Peter Weber
08/30/2011 7:37 AM
post88482
|
Re: spawn system call error
ups,
I mean:
how about a memset(&inherit, 0, sizeof(inherit));
:-)
|
|
|
shakthi b
|
Re: spawn system call error
|
shakthi b
08/30/2011 7:41 AM
post88483
|
Re: spawn system call error
no dude. i ve tried i got some error like:
spawn : no such file or directory..
dont know what to do??
|
|
|
Peter Weber
|
Re: spawn system call error
|
Peter Weber
08/30/2011 7:53 AM
post88485
|
Re: spawn system call error
What do you expect to get?
Setting SPAWN_EXEC means you want to replace the current process with a new one.
In argv[0] you set 'child' but in the path you set 'sharedmemorymodel'.
So what do you expect from this program?
If you want to search the PATH variable for the executable you want to replace the running process with, you should use
the spawnp() variant.
> how about a memset(&inherit, 0, sizeof(struct inherit)) ? :-)
>
>
>
> > //code
> >
> > /*#include <spawn.h>
> > #include<stdio.h>
> > #include<stdlib.h>
> > #include<unistd.h>
> > int main(int argc,char **argv)
> > {
> > char *args[]={"child",NULL};
> > int i;
> > pid_t pid;
> > struct inheritance inherit;
> > for (i=0;i<3;i++)
> > {
> > inherit.flags |= SPAWN_EXEC;
> > if((pid=spawn("sharedmemorymodel",0,NULL,&inherit,args,environ))==-1)
> > perror("spawn failed");
> > else
> > printf("the spawn id %d",pid);
> > }
> > return 0;
> > }
> > */
> >
> > i have tried this code in qnx momentics and i used vmware to run qnx rtos..
>
> > while executing this code i got error like spawn:not supported.. couldn't
> find
> > out what is the problem.. whether running in windows, executing qnx exe is
>
> > not supportable? or some other problem. pls help me asap
> >
> > thanks in advance,
> > shakthi
>
>
|
|
|
shakthi b
|
Re: spawn system call error
|
shakthi b
08/30/2011 7:59 AM
post88486
|
Re: spawn system call error
//code
/*#include <spawn.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main(int argc,char **argv)
{
char *args[]={"spawnexample",NULL};
int i;
pid_t pid;
struct inheritance inherit;
memset(&inherit, 0, sizeof(inherit));
inherit.flags =0;
if((pid=spawn("spawnexample",0,NULL,&inherit,args,0))==-1)
perror("spawn failed");
else
printf("the spawn id %d",pid);
return 0;
}
*/
k dude i changed my code
my program name is spawnexample.. i need this pgm should create one child process and that process execute my same
program..now also am facing same error..
|
|
|
Peter Weber
|
Re: spawn system call error
|
Peter Weber
08/30/2011 8:09 AM
post88487
|
Re: spawn system call error
> //code
>
> /*#include <spawn.h>
> #include<stdio.h>
> #include<stdlib.h>
> #include<unistd.h>
> int main(int argc,char **argv)
> {
> char *args[]={"spawnexample",NULL};
> int i;
> pid_t pid;
> struct inheritance inherit;
> memset(&inherit, 0, sizeof(inherit));
> inherit.flags =0;
> if((pid=spawn("spawnexample",0,NULL,&inherit,args,0))==-1)
> perror("spawn failed");
> else
> printf("the spawn id %d",pid);
> return 0;
> }
> */
>
> k dude i changed my code
>
> my program name is spawnexample.. i need this pgm should create one child
> process and that process execute my same program..now also am facing same
> error..
you don't get a child process that way. As I said in the previous post, the SPAWN_EXEC flags _REPLACES_ your _CURRENT_
executable. spawn doesn't return at all.
BTW: The first argument <path> must be an absolute path to the executable as described in the documentation.
|
|
|
shakthi b
|
Re: spawn system call error
|
shakthi b
08/30/2011 8:11 AM
post88488
|
Re: spawn system call error
see now i removed the flag and set it as zero and also change the argument as executable that is my current pgm name...
see the code properly.. still i face the same error.
|
|
|
Peter Weber
|
Re: spawn system call error
|
Peter Weber
08/30/2011 8:13 AM
post88489
|
Re: spawn system call error
> see now i removed the flag and set it as zero and also change the argument as
> executable that is my current pgm name... see the code properly.. still i face
> the same error.
the path is still relative not absolute.
whether use spawnp to search in the PATH environment (if it points to your executable) or make the path an absolute path
.
|
|
|
shakthi b
|
Re: spawn system call error
|
shakthi b
08/30/2011 8:17 AM
post88490
|
Re: spawn system call error
i dint understood dude.. can you change my code and post it here.. where to change.. see it automatically locate the
path rite.. then y should i have to specify path and it will not accept the path of the windows rite..
|
|
|
Peter Weber
|
Re: spawn system call error
|
Peter Weber
08/30/2011 8:21 AM
post88491
|
Re: spawn system call error
> i dint understood dude.. can you change my code and post it here.. where to
> change.. see it automatically locate the path rite.. then y should i have to
> specify path and it will not accept the path of the windows rite..
#include <stdlib.h>
#include <stdio.h>
#include<unistd.h>
#include <spawn.h>
int main(int argc,char **argv) {
char *args[]={"hello_g",NULL};
int i;
pid_t pid;
struct inheritance inherit;
memset(&inherit, 0, sizeof(inherit));
inherit.flags =0;
if((pid=spawn("/tmp/hello_g",0,NULL,&inherit,args,0))==-1)
perror("spawn failed");
else
printf("the spawn id %d",pid);
return 0;
}
you can't start a QNX executable on windows.
Please start this program on QNX natively from /tmp directory.
So you should have:
/tmp/hello_g as an executable on a QNX RTOS.
|
|
|
|