Should I set errno?

c, errno

Solution

This is a bit old, but errno - manual section 3 says that you can directly assign to it, even though it is a macro, and it will be thread local

Problem

I'm writing a module which exports an interface similar to `send` and `recv`. Since those functions are supposed to return respectively the number of sent and received bytes, I cannot do proper error management as I would do normally (i.e. using enumeratives and returning mnemonic values). In a situation like this should I set `errno` as the standard library does? If so, since `errno` is thread specific, is there a particular way of writing on it, or can I simply assign a value to it? Edit: experimenting it I noticed that setting `errno` by assignment is working. Still: is this safe and portable for any system?

Original source

Related problems