P M
P M

Reputation: 137

how is errno set by ioctl() in c

I'm using ioctl() to check if the read-end of a pipe would block. I set ioctl(the_pipe[0], FIONBIO, ...) (I'm not sure what the 3rd parameter is supposed to be, can I set it to NULL?).

As I understand, read(the_pipe[0], buf, buf_len); is supposed to set an error code for EWOULDBLOCK (EAGAIN), but where is that error code set, how do I get it?

Thanks

Upvotes: 0

Views: 1296

Answers (2)

AProgrammer
AProgrammer

Reputation: 52284

errno is available after having included errno.h

Upvotes: 2

mpez0
mpez0

Reputation: 2883

Note also that errno is set by system calls, but is not cleared. That is, if you aren't checking for errors after each system call or explicitly clearing errno prior to the call in question, you won't be sure which system call set errno.

Upvotes: 0

Related Questions