Skip navigation.
Home
The QNX Community Portal

View topic - system() API sometimes calls sh -c "my_command"

system() API sometimes calls sh -c "my_command"

Discussion about the QNX6 OS.

system() API sometimes calls sh -c "my_command"

Postby rahil » Sat Jan 22, 2011 8:23 am

Hi,

In my app code, I'm using system() API to execute "my_command" like this:

int iRetVal = system( "my_command" );

Now, most of the time it works. But sometimes, the system() API doesn't return at all. When I get suspicious of that, I use pidin to find out whats happening? It shows me this:

xxxxx (PID) sh- c my_command

I thought that the command "sh -c my_command" is the usual way system() API works. So, to test it, I used pidin when thing were running perfectly.
To my astonishment, the results were:

xxxxx (PID) my_command

This result is also the same when I run it from the command line.

Can anybody tell me whats wrong here?

I'm using QNX 6.4.0
rahil
Active Member
 
Posts: 75
Joined: Wed Feb 11, 2009 12:13 pm
Location: India

RE: system() API sometimes calls sh -c "my_command"

Postby mario » Mon Jan 24, 2011 1:45 pm

I'm guessing that sh "becomes" you process when it is running properly ( that is what exec() does ). But when it's not running sh may be unable to start your command?
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: system() API sometimes calls sh -c "my_command"

Postby maschoen » Mon Jan 24, 2011 2:12 pm

I think the question is, what state is "sh -c my_command" in? Is it Reply blocked to some process? Maybe Proc?
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: RE: system() API sometimes calls sh -c "my_command&

Postby rahil » Tue Jan 25, 2011 5:58 am

mario wrote:I'm guessing that sh "becomes" you process when it is running properly ( that is what exec() does ). But when it's not running sh may be unable to start your command?


Thanks mario.
If that is true, then what shall be done to avoid it?
rahil
Active Member
 
Posts: 75
Joined: Wed Feb 11, 2009 12:13 pm
Location: India

RE: Re: RE: system() API sometimes calls sh -c "my_comm

Postby maschoen » Tue Jan 25, 2011 6:03 am

To avoid what? You don't know why it is happening yet. When you find out, you will know how to avoid it.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: RE: system() API sometimes calls sh -c "my_command&

Postby rahil » Tue Jan 25, 2011 6:11 am

maschoen wrote:I think the question is, what state is "sh -c my_command" in? Is it Reply blocked to some process? Maybe Proc?


Thanks maschoen.
I'll try to reproduce the problem and see the thread state then.
rahil
Active Member
 
Posts: 75
Joined: Wed Feb 11, 2009 12:13 pm
Location: India


Return to QNX6 - OS

Who is online

Users browsing this forum: Bing [Bot] and 1 guest