#StackBounty: #linux-kernel #file-descriptors #gpio #ioctl Are ioctl calls blocking?

Bounty: 50

I am writing some code around libgpiod’s interface. For example, I want to set a line to output high. Under the hood, libgpiod opens an fd provided by the kernel for the line, and then calls ioctl(fd, GPIO_V2_LINE_SET_VALUES_IOCTL, ...).

My questions are:

  • Is this particular ioctl() call (with the GPIO_V2... argument) theoretically (potentially) blocking in the same way that writing to an arbitrary file descriptor can be?

  • Are ioctl() calls in general theoretically blocking? For example, requesting the line in the first place also involves an ioctl() on a fd for the chip. What about I2C ioctl()s?

  • If it is blocking, is the underlying fd in the line struct (line->fd_handle->fd) the one I need to wait on in an event loop (eg. epoll() or an abstracted event library like libuv)?

I have tried to answer this question through research, but (a) searching for any combination of "ioctl" and "blocking" just gives results for setting a fd to be blocking or not and (b) it’s not in the man pages or kernel docs that I can find.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.