Skip navigation.
Home
The QNX Community Portal

View topic - [photon] - after fork , execv problem

[photon] - after fork , execv problem

Isn't the name clear?

[photon] - after fork , execv problem

Postby pklooks » Mon Nov 12, 2007 9:20 am

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: Select all
 if ( fork() == 0)
{
      if ( execv("/bin/rz","rz",NULL) < 0)
     {
               printf("err");
      }
}


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

Code: Select all
$> 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,
pklooks
New Member
 
Posts: 3
Joined: Mon Nov 12, 2007 8:32 am

RE: [photon] - after fork , execv problem

Postby micro » Mon Nov 12, 2007 12:50 pm

Do you run this in a console in photon?
Try calling a shell with the parameter to start rz.
micro
Senior Member
 
Posts: 458
Joined: Thu Jul 22, 2004 8:41 pm

RE: [photon] - after fork , execv problem

Postby pklooks » Tue Nov 13, 2007 9:10 am

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....
pklooks
New Member
 
Posts: 3
Joined: Mon Nov 12, 2007 8:32 am

RE: [photon] - after fork , execv problem

Postby qnxloader » Tue Nov 13, 2007 11:40 am

try "system" or :
execv("/bin/rz >> /dev/null","rz",NULL)
qnxloader
Senior Member
 
Posts: 206
Joined: Mon Oct 06, 2003 8:29 am

RE: [photon] - after fork , execv problem

Postby micro » Tue Nov 13, 2007 4:40 pm

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
micro
Senior Member
 
Posts: 458
Joined: Thu Jul 22, 2004 8:41 pm

Re: RE: [photon] - after fork , execv problem

Postby pklooks » Wed Nov 14, 2007 1:19 am

=========================================
"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"
pklooks
New Member
 
Posts: 3
Joined: Mon Nov 12, 2007 8:32 am


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 2 guests