8000 uv_pipe_open does not work with files · Issue #1218 · luvit/luvit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
uv_pipe_open does not work with files #1218
Open
@q962

Description

@q962

uv.pipe_open(stdout, 1)

This usage appears in libuv's test code. But it is preceded by an assertion.

https://github.com/libuv/libuv/blob/1b084f7bbe4ae6d90e06600d789126f3b37941d8/test/test-stdio-over-pipes.c#L225-L240

On Linux this does not throw an error. Everything runs fine.
But on Windows it does not.
uv_pipe_open will return UV_ENOTSOCK

This results in errors when setting up output redirection for luvit.

code.c
#include <stdio.h>
#include <uv.h>

uv_loop_t* loop = NULL;

void open_done( uv_fs_t* req )
{
	if ( req->result < 0 ) {
		printf( "error\n" );
		return;
	}

	printf( "result: %lld\n", req->result );

	uv_file filed = ( uv_file )req->result;
	printf( "%d\n", uv_guess_handle( filed ) );

	int       ret  = 0;
	uv_pipe_t pipe = {};

	ret = uv_pipe_init( loop, &pipe, 0 );
	ret = uv_pipe_open( &pipe, filed );
	printf( "pipe_open ret : %d\n", ret );

	uv_buf_t b[] = { { .base = "3", .len = 1 }, { .base = "4", .len = 1 } };
	uv_try_write( ( void* )&pipe, b, 2 );

	uv_os_fd_t pipe_fd = 0;
	ret                = uv_fileno( ( void* )&pipe, &pipe_fd );
	printf( "fileno ret : %d, fd: %p\n", ret, pipe_fd );
}

int main( int argc, char** argv )
{
	loop = uv_loop_new();

	uv_fs_t file_req;
	uv_fs_open( loop, &file_req, argv[ 1 ], O_CREAT | O_RDWR, 0644, open_done );

	uv_run( loop, UV_RUN_DEFAULT );

	return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0