Created
June 6, 2012 00:51
-
-
Save piscisaureus/2879181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uv_pipe_t pipe1, *pipe2; | |
// pipe2 is the pipe end that the parent process will use | |
pipe2 = malloc(sizeof *pipe2) | |
// PIPE_SPAWN_SAFE creates a pipe that is safe for using with | |
// uv_spawn(). When the flag is not used, spawn() will not reject | |
// the pipe end but the child process may not be able to use it. | |
uv_pipe_init2(&pipe1, PIPE_SPAWN_SAFE | PIPE_READABLE); | |
uv_pipe_init2(pipe2, PIPE_WRITEABLE); | |
uv_pipe_link(&pipe1, &pipe2); // Connects 2 unconnected pipes together | |
uv_spawn(xxx, stdin:pipe1) | |
// uv_close_pipe_sync only works if the pipe is inactive, | |
// e.g. not busy reading/writing/connecting/listerning. | |
// otherwise the function abort()s | |
uv_close_pipe_sync(&pipe1); | |
// write somethin' | |
uv_write(pipe2, "hello") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment