Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - system() Surprise of expectation: Page 1 of 4 (4 Items)
   
system() Surprise of expectation  
There is a simple code:

#include <stdio.h>
#include <stdlib.h>

Int main (int argc, char * argv [])
{
   Int ret;
...
  ret = system ("uname -a"); // any sh command
...
}

system () function is executed without an error,
The output of the command "uname -a" is correct, and ret = 0;

Now twu controllers A1 and A2 in the Qnet network, and on the remote controller A2 
there is a file / net / A2 / tmp / tmpfile.

#include <stdio.h>
#include <stdlib.h>
Int main (int argc, char * argv [])
{
   Int ret, fp;
...
   fp = open ("/ net / A2 / tmp / tmpfile", O_RDWR);
   ret = system ("uname -a");
...
}

When the program is executed on the A1 controller and when the remote file is successfully opened,
So that fp> 0, the system ("uname -a") function fails with an error, "sh: can not fork, try again" is output.

The error code is ret = 256, "Socket is already connected".

How can I explain the failure of system () to call sh and execute the command when the file on the remote controller is 
open?

Thank you.