0

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?

Jay
  • 24,173
  • 25
  • 93
  • 141
  • Are you including '``' - and not writing '`extern int errno;`'? Are you getting error indications back from the system calls? The `errno` variable is never zeroed by the library, but is only relevant when the system call returns an error indication. – Jonathan Leffler Mar 26 '10 at 15:38
  • Yes. I am including and not including 'extern int errno'. Does it matter? My code compiles and links fine. My system calls are definitely returning error indication. – Jay Mar 26 '10 at 15:48
  • errno is not really an 'extern int errno;'. This wouldn't allow for multiple threads because they would have to share one errno and you'd never know which thread the value really belonged to. It's a macro that expands to some code to access the thread local version, so it should matter. – nategoose Mar 26 '10 at 15:56

2 Answers2

1

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
  • 37,894
  • 24
  • 81
  • 116
0

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
  • 121
  • 2