Skip to content

Opening a named pipe hangs libuv #357

Closed
@haesbaert

Description

@haesbaert

Luv.File.open_ on a named pipe hangs until there is input, this is not luv's fault, it's in libuv.
We're supposed to use uv_pipe_t on a named pipe, the manual explains it how, which means that if we want Path.open_in to work, we would have to first stat the file descriptor and do the uv_fs_t <> uv_pipe_t dance.

#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
#include <unistd.h>
#include <err.h>

int
main(int argc, char *argv[])
{
	uv_loop_t *loop = uv_default_loop();
	uv_fs_t uv_fs_req;
	int fd;

	fd = uv_fs_open(loop, &uv_fs_req, argv[1], O_RDONLY, 0644, NULL);
	if (fd == -1)
		err(1, "uv_fs_open");
	printf("fd=%d\n", fd);

	printf("[%llu] running\n", (unsigned long long)getpid());
	uv_run(loop, UV_RUN_DEFAULT);

	uv_loop_close(loop);
	return (0);
}
cc -o uv_named_pipes uv_named_pipes.c -Wall -luv && file /tmp/sometext && ./uv_named_pipes /tmp/sometext
/tmp/sometext: ASCII text
fd=9
[3591398] running
 cc -o uv_named_pipes uv_named_pipes.c -Wall -luv && file /tmp/somepipe && ./uv_named_pipes /tmp/somepipe
/tmp/somepipe: fifo (named pipe)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions