Chromium Code Reviews| Index: ports/nacl-spawn/nacl_spawn.cc |
| diff --git a/ports/nacl-spawn/nacl_spawn.cc b/ports/nacl-spawn/nacl_spawn.cc |
| index 59cd9a955dc0b8af195414c7a093b9e8601cf245..77a99fe03c9ef77fb3804335a1ab58e9c1c16e2c 100644 |
| --- a/ports/nacl-spawn/nacl_spawn.cc |
| +++ b/ports/nacl-spawn/nacl_spawn.cc |
| @@ -354,7 +354,8 @@ static int CloneFileDescriptors(struct PP_Var envs_var) { |
| char entry[100]; |
| snprintf(entry, sizeof entry, |
| "NACL_SPAWN_FD_SETUP_%d=pipe:%d:%d:%d", count++, fd, |
| - static_cast<int>(st.st_ino), st.st_rdev == O_WRONLY); |
| + static_cast<int>(st.st_ino), |
| + (st.st_rdev & O_WRONLY) == O_WRONLY); |
| nspawn_array_appendstring(envs_var, entry); |
| } else if (S_ISLNK(st.st_mode)) { |
| // Unsupported. |
| @@ -689,6 +690,11 @@ void jseval(const char* cmd, char** data, size_t* len) { |
| // Create a javascript pipe. pipefd[0] will be the read end of the pipe |
| // and pipefd[1] the write end of the pipe. |
| int nacl_spawn_pipe(int pipefd[2]) { |
| + return nacl_spawn_pipe_flags(0, pipefd); |
| +} |
| + |
| +// Same as above with flags. |
| +int nacl_spawn_pipe_flags(int flags, int pipefd[2]) { |
| if (pipefd == NULL) { |
| errno = EFAULT; |
| return -1; |
| @@ -705,8 +711,8 @@ int nacl_spawn_pipe(int pipefd[2]) { |
| int write_fd; |
| char path[100]; |
| sprintf(path, "/apipe/%d", id); |
| - read_fd = open(path, O_RDONLY); |
| - write_fd = open(path, O_WRONLY); |
| + read_fd = open(path, O_RDONLY | flags); |
|
Pete Williamson
2016/02/29 20:53:47
What would happen here if flags had O_WRONLY set?
bradnelson
2016/03/03 18:04:03
Nothing good :-)
|
| + write_fd = open(path, O_WRONLY | flags); |
| if (read_fd < 0 || write_fd < 0) { |
| if (read_fd >= 0) { |
| close(read_fd); |