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..98780e068acb4d0acb4b4f6d58d7804b21d071ea 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,10 @@ 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); |
| + // Filter out O_RDONLY + O_WRONLY |
|
bsy_cr
2016/03/03 18:43:33
sorry about the drive-by.
filtering out should be
bradn
2016/03/03 19:11:40
Thanks, that actually caught a mistake!
Good to k
|
| + flags &= O_RDONLY | O_WRONLY; |
| + read_fd = open(path, O_RDONLY | flags); |
| + write_fd = open(path, O_WRONLY | flags); |
| if (read_fd < 0 || write_fd < 0) { |
| if (read_fd >= 0) { |
| close(read_fd); |