OpenQNX :: The QNX Community Portal

Jul 19, 2008 - 03:27 PM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 36 unlogged users and 1 registered user online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
pklooks
Post subject: [photon] - after fork , execv problem  PostPosted: Nov 12, 2007 - 09:20 AM
New Member


Joined: Nov 12, 2007
Posts: 3

Sorry, I'm foor at speaking english.

Now, I'm making Serial Communication Program.
In this program, when I click button ," Receive File" , It fork and execute command ,"rz".

Code:

 if ( fork() == 0)
{
      if ( execv("/bin/rz","rz",NULL) < 0)
     {
               printf("err");
      }
}


Ths code has no problem in console,
no error: fork, execv

Code:

$> gcc main.c
$> ./a.out
 .... rz .... sz filename ... ready.....



but not in photon.

build done ,and it executed,
no error: fork, execv

after I clicked button , it forked and executed.
But forked( child ) proccess was killed at once.

when I put command (any gui program) in parameter of execv function and execute it , the gui program did work

only command ( any console program ) in parameter of execv function. it occured this problem ,
I don't know why it do that in photon.

Please, Let me know the reason,
 
 View user's profile Send private message  
Reply with quote Back to top
micro
Post subject: RE: [photon] - after fork , execv problem  PostPosted: Nov 12, 2007 - 12:50 PM
Senior Member


Joined: Jul 22, 2004
Posts: 327

Do you run this in a console in photon?
Try calling a shell with the parameter to start rz.
 
 View user's profile Send private message  
Reply with quote Back to top
pklooks
Post subject: RE: [photon] - after fork , execv problem  PostPosted: Nov 13, 2007 - 09:10 AM
New Member


Joined: Nov 12, 2007
Posts: 3

I called a shell with the parameter to start rz.

no problem

after I build my program In momentics and run it , when I click the button , it occurs problem.

Fork and excute is done , but child proccess is killed at once.

um....
 
 View user's profile Send private message  
Reply with quote Back to top
qnxloader
Post subject: RE: [photon] - after fork , execv problem  PostPosted: Nov 13, 2007 - 11:40 AM
Senior Member


Joined: Oct 06, 2003
Posts: 147

try "system" or :
execv("/bin/rz >> /dev/null","rz",NULL)
 
 View user's profile Send private message  
Reply with quote Back to top
micro
Post subject: RE: [photon] - after fork , execv problem  PostPosted: Nov 13, 2007 - 04:40 PM
Senior Member


Joined: Jul 22, 2004
Posts: 327

i actually thought of something like:

char* arg_list[] = { "/usr/photon/bin/pterm", "-z", "/usr/bin/rz" };
execv( "/usr/photon/bin/pterm", arg_list );

what actually should call:

pterm -z /usr/bin/rz

This opens an Photon Terminal Window where your output is directed to.
The version by qnxloader directs the output to /dev/null ;P
 
 View user's profile Send private message  
Reply with quote Back to top
pklooks
Post subject: Re: RE: [photon] - after fork , execv problem  PostPosted: Nov 14, 2007 - 01:19 AM
New Member


Joined: Nov 12, 2007
Posts: 3

=========================================
"micro" :

i actually thought of something like:

char* arg_list[] = { "/usr/photon/bin/pterm", "-z", "/usr/bin/rz" };
execv( "/usr/photon/bin/pterm", arg_list );

what actually should call:

pterm -z /usr/bin/rz

This opens an Photon Terminal Window where your output is directed to.
The version by qnxloader directs the output to /dev/null ;P
===========================================

Thank you,

I adjust this solution. it is no problem.

but I don't know how to adjust other solution. I can't do it.

as if I only do fork it, it work. it do not excute it, "rz"
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.