Albrecht Uhlmann
|
Re: system() Surprise of expectation
|
Albrecht Uhlmann
08/29/2017 7:11 AM
post117988
|
Re: system() Surprise of expectation
Hello Leonid,
please tell us what QNX version you are using (6.5, 6.6 or 7.0), and what processors machines A1 and A2 have (presume
both are x86 but please tell).
Regards,
Albrecht
|
|
|
Roger Maclean
|
Re: system() Surprise of expectation
|
Roger Maclean
08/29/2017 8:47 AM
post117991
|
Re: system() Surprise of expectation
What if you change the open from O_RDWR to 'O_RDWR | O_CLOEXEC'. My guess
is that the fork is failing to dup the fds you have open.
On 2017-08-14, 1:36 AM, "Leonid Khait" <community-noreply@qnx.com> wrote:
>> 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 two 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.
>
|
|
|