Skip to content

Non‑blocking pipe writes never return EAGAIN (unbounded pipe buffer) #6148

@artemyarulin

Description

@artemyarulin

When using a non‑blocking pipe O_NONBLOCK, write() should eventually return -1 with errno=EAGAIN/EWOULDBLOCK once the pipe buffer is full. In WASIX it never does, because the pipe implementation is effectively unbounded. This breaks back pressure semantics and can cause OOM

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(void) {
    int fds[2]; 
    pipe(fds);
    fcntl(fds[1], F_SETFL, fcntl(fds[1], F_GETFL, 0) | O_NONBLOCK);
    while (write(fds[1], "x", 1) == 1) {

    }
    // BUG: write never returns -1/EAGAIN on a non-blocking pipe
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions