tags:

views:

166

answers:

2

I am running my code on VxWorks PPC and incase of system call failures especially for socket send / recv functions, errno returns 0 always.

After some analysis I found that, errno returns 0 incase of all system call failures.

Is there any initialization which I should be doing for errno to return correct values?

+1  A: 

From a shell (either kernel or host), if you type the 'i' command, you will get a list of your tasks. One of the field is the errno value. Find the task that has an error and the errno value should be set.

When checking errno, you HAVE to be in the same task that caused the error:

if(ERROR = someSystemFunction())
  printf("errno=%x", errno);

You can't be at the shell and expect to print errno

-> errno     (<---- will NEVER work)
errno:0x123455 value: 0 = 0x0
Benoit
A: 

errnoGet() will return to you the errno of the task in which it is executed. See the documentation on errnoLib for retrieving the errno of a different task

fanch