Search code examples
linuxnginxsignals

Program received signal SIGIO


I see following error in my NGINX's error.log:

[notice] 12451#0: signal 29 (SIGIO) received

I want to know in which case does a program receive a SIGIO?


Solution

  • For asynchronous signalling, the code should do these steps.

    First, you should allow your process to receive SIGIO, and then your socket or pipe should be put to async mode.

    Search for these lines in your code.

    // Allow the process to receive SIGIO
    fcntl(fd, F_SETOWN, getpid());
    

    and

    // Make socket/pipe non-blocking
    fcntl(fd, F_SETFL, FASYNC);
    

    or

    // Make socket/pipe non-blocking
    fcntl(fd, F_SETFL, O_NONBLOCK);
    

    Keywords to search for are: F_SETOWN, FASYNC and O_NONBLOCK.