Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - spawn system call error: Page 1 of 2 (11 Items)
   
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[]={"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
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


Re: spawn system call error  
ups,
I mean:
how about a memset(&inherit, 0, sizeof(inherit));
:-)
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?? 
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
> 
> 


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..
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.

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.
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
.
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..