-
Notifications
You must be signed in to change notification settings - Fork 7
cause error in uv_pipe_open(stdin/stdout) #120
Comments
You're trying to open file descriptor 0 but that isn't a name pipe, it's the console. What exactly is unexpected? |
Hello, bnoordhuis. test code: #include <string>
#include <iostream>
#include <stdio.h>
#include <uv.h>
static void my_alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
buf->base = (char*)malloc(suggested_size);
buf->len = suggested_size;
}
static void read_stdin_cb(uv_stream_t* stream,
ssize_t nread,
const uv_buf_t* buf) {
std::string temp(buf->base, buf->len);
std::cerr << "STDIN: " << temp << std::endl;
}
int main(int argc, char **argv)
{
uv_loop_t *loop = uv_default_loop();
uv_pipe_t stdin_pipe = { 0 };
uv_pipe_t stdout_pipe = { 0 };
int res;
uv_pipe_init(loop, &stdin_pipe, 0);
res = uv_pipe_open(&stdin_pipe, 0); // <---------- return UV_EINVAL
std::cerr << "open stdin : " << res << std::endl;
uv_pipe_init(loop, &stdout_pipe, 0);
uv_pipe_open(&stdout_pipe, 1);
std::cerr << "open stdout : " << res << std::endl;
uv_read_start((uv_stream_t*)&stdin_pipe, my_alloc_cb, read_stdin_cb);
uv_run(loop, UV_RUN_DEFAULT);
return 0;
} console out:
|
Then why don't you use
That's because clion's terminal emulator uses a named pipe to capture the output. |
I also tried tty but it didn't work in all cases. If run with CreateProcess in windows or child_process in node.js, the tty will not work. |
https://github.com/libuv/libuv/blob/af45b6ba2f2c506ae18dd24481e24db17b8269e7/src/win/pipe.c#L271 In the code above, I get an ERROR_INVALID_FUNCTION error. |
Right, you're looking for a one-stop solution but there isn't one - libuv doesn't paper over such details. You need to switch between I'm moving this to libuv/help because everything is working as expected as far as libuv is concerned. |
Same error : https://groups.google.com/forum/#!msg/libuv/iYmwxzRyemU/BBDeikdBBAAJ
Seems like a long time ago.
Still not fixed?
The text was updated successfully, but these errors were encountered: