Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - spawn error: (10 Items)
   
spawn error  
int main()
{
    char  *args[] = {"child", NULL };
    pid_t  pid;
    struct inheritance inherit;

    pid =  spawn("child",0,NULL,&inherit,args, environ);
    if (pid == -1)
    	perror("spawn() failed");
    else
    	printf("spawned child, pid = %d\n", pid);

	return (0);
}

When i run the above code I get the error -> spawn() failed: No such file or directory

I also tried with /proc/boot and /bin path to the child. But still getting error.

Cannot figure out where the error lies.

Thanks a lot for the help

Abhi
Re: spawn error  
  What is the full path to "child" on your system?



On 07/09/10 08:50, Abhishek Ashtekar wrote:
> int main()
> {
>      char  *args[] = {"child", NULL };
>      pid_t  pid;
>      struct inheritance inherit;
>
>      pid =  spawn("child",0,NULL,&inherit,args, environ);
>      if (pid == -1)
>      	perror("spawn() failed");
>      else
>      	printf("spawned child, pid = %d\n", pid);
>
> 	return (0);
> }
>
> When i run the above code I get the error ->  spawn() failed: No such file or directory
>
> I also tried with /proc/boot and /bin path to the child. But still getting error.
>
> Cannot figure out where the error lies.
>
> Thanks a lot for the help
>
> Abhi
>
>
>
> _______________________________________________
>
> OSTech
> http://community.qnx.com/sf/go/post59058
>
Re: spawn error  
on QNX Target board, i have the following .....
bin     dev     etc     home    proc    tmp     usr

the proc/boot has been sym_linked to /bin

the "child" should  be created at the specified path in spawn command, right ?

Re: spawn error  
Spawn creates and executes a new process. You provide it the full path to a file you want it to execute, and it creates 
a new process to execute that file, see the references below.

Give this a try, use "pidin" instead of "child". This will spawn a process that will "run" pidin, which will display 
some nice output for you proving what I am saying and illustrating the usage of the function. I think that will clear 
this up for you.


Reference:
http://www.qnx.com/developers/docs/6.4.1/neutrino/lib_ref/s/spawn.html
Re: spawn error  
as written in spawn() doc, this call is not checking your PATH env variable.
So you either have to specify the full path to your binary,
or you should use a call from the spawnXp() familiy

/hp
Re: spawn error  
You really should be zeroing the inherit structure - and then setting 
the appropriate flags.

On 10-07-09 8:50 AM, Abhishek Ashtekar wrote:
> int main()
> {
>      char  *args[] = {"child", NULL };
>      pid_t  pid;
>      struct inheritance inherit;
>
>      pid =  spawn("child",0,NULL,&inherit,args, environ);
>      if (pid == -1)
>      	perror("spawn() failed");
>      else
>      	printf("spawned child, pid = %d\n", pid);
>
> 	return (0);
> }
>
> When i run the above code I get the error ->  spawn() failed: No such file or directory
>
> I also tried with /proc/boot and /bin path to the child. But still getting error.
>
> Cannot figure out where the error lies.
>
> Thanks a lot for the help
>
> Abhi
>
>
>
> _______________________________________________
>
> OSTech
> http://community.qnx.com/sf/go/post59058
>
>    

-- 
cburgess@qnx.com
Re: spawn error  
@ Gervais:
    thanks for Your reply.
    The program worked with /bin/pidin, was able to see expected output on console
    I guess, I was forgetting, the difference between a program and a process.
    That means I have to create an executable file of the process that i want to     
    create and execute and store at the path. 
    Is that a correct and sufficient understanding ?
    
@ Colin
    The program works without -->  inherit.flags = 0;


 - Abhi
    
Re: spawn error  
Your understanding at this point is accurate. If you have any other questions don't hesitate - things will appear 
confusing at first, but then it all becomes clear as you progress.
Re: spawn error  
On Fri, 2010-07-09 at 08:50 -0400, Abhishek Ashtekar wrote:
> When i run the above code I get the error -> spawn() failed: No such file or directory

What version of Neutrino are you using?  In the upcoming 6.5.0 there
were changes made to spawn() to improve its POSIX compliance (and the
path search in particular).  There is still an open problem report
(77603) which indicates that the current implementation doesn't search
the current directory, which may or may not be a real bug (although
apparently Linux and BSD both do so, so it probably is a bug).
RE: spawn error  
There is no binary called 'child' under the path specified. And we can
not expect spawn to create a binary for you.



-----Original Message-----
From: Neil Schellenberger [mailto:community-noreply@qnx.com] 
Sent: Friday, July 09, 2010 10:52 AM
To: ostech-core_os
Subject: Re: spawn error

On Fri, 2010-07-09 at 08:50 -0400, Abhishek Ashtekar wrote:
> When i run the above code I get the error -> spawn() failed: No such
file or directory

What version of Neutrino are you using?  In the upcoming 6.5.0 there
were changes made to spawn() to improve its POSIX compliance (and the
path search in particular).  There is still an open problem report
(77603) which indicates that the current implementation doesn't search
the current directory, which may or may not be a real bug (although
apparently Linux and BSD both do so, so it probably is a bug).




_______________________________________________

OSTech
http://community.qnx.com/sf/go/post59083