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


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

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?

I think the question is, what state is “sh -c my_command” in? Is it Reply blocked to some process? Maybe Proc?

Thanks mario.
If that is true, then what shall be done to avoid it?

To avoid what? You don’t know why it is happening yet. When you find out, you will know how to avoid it.

Thanks maschoen.
I’ll try to reproduce the problem and see the thread state then.