Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
api: change the spawn api to allow using existing streams for stdio
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed May 31, 2012
1 parent aecddfe commit 44c72a9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions include/uv.h
Expand Up @@ -1165,15 +1165,17 @@ UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai);

/* uv_spawn() options */
typedef enum {
UV_IGNORE = 0x00,
UV_CREATE_PIPE = 0x01,
/*
* UV_READABLE_PIPE and UV_WRITABLE_PIPE flags are set from
* the child process perspective.
UV_IGNORE = 0x00,
UV_CREATE_PIPE = 0x01,
UV_INHERIT_FD = 0x02,
UV_INHERIT_STREAM = 0x04,

/* When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
* determine the direction of flow, from the child process' perspective. Both
* flags may be specified to create a duplex data stream.
*/
UV_READABLE_PIPE = 0x02,
UV_WRITABLE_PIPE = 0x04,
UV_RAW_FD = 0x08
UV_READABLE_PIPE = 0x10,
UV_WRITABLE_PIPE = 0x20,
} uv_stdio_flags;

typedef struct uv_stdio_container_s {
Expand Down
2 changes: 1 addition & 1 deletion src/unix/process.c
Expand Up @@ -151,7 +151,7 @@ static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2],
}

return uv__make_socketpair(fds, 0);
} else if (container->flags & UV_RAW_FD) {
} else if (container->flags & UV_INHERIT_FD) {
if (container->data.fd == -1) {
errno = EINVAL;
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/win/process.c
Expand Up @@ -945,7 +945,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
continue;
}

if (options.stdio[i].flags & UV_RAW_FD) {
if (options.stdio[i].flags & UV_INHERIT_FD) {
err = duplicate_fd(loop, options.stdio[i].data.fd, &child_stdio[i]);
} else if (options.stdio[i].data.stream->type == UV_NAMED_PIPE) {
pipe = (uv_pipe_t*)options.stdio[i].data.stream;
Expand Down
2 changes: 1 addition & 1 deletion test/test-spawn.c
Expand Up @@ -217,7 +217,7 @@ TEST_IMPL(spawn_stdout_to_file) {

options.stdio = stdio;
options.stdio[0].flags = UV_IGNORE;
options.stdio[1].flags = UV_RAW_FD;
options.stdio[1].flags = UV_INHERIT_FD;
options.stdio[1].data.fd = file;
options.stdio_count = 2;

Expand Down

0 comments on commit 44c72a9

Please sign in to comment.