Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2014 The Native Client Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Emulates spawning/waiting process by asking JavaScript to do so. | 5 // Emulates spawning/waiting process by asking JavaScript to do so. |
| 6 | 6 |
| 7 // Include quoted spawn.h first so we can build in the presence of an installed | 7 // Include quoted spawn.h first so we can build in the presence of an installed |
| 8 // copy of nacl-spawn. | 8 // copy of nacl-spawn. |
| 9 #define IN_NACL_SPAWN_CC | 9 #define IN_NACL_SPAWN_CC |
| 10 #include "spawn.h" | 10 #include "spawn.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 extern int nacl_spawn_ppid; | 46 extern int nacl_spawn_ppid; |
| 47 | 47 |
| 48 struct NaClSpawnReply { | 48 struct NaClSpawnReply { |
| 49 pthread_mutex_t mu; | 49 pthread_mutex_t mu; |
| 50 pthread_cond_t cond; | 50 pthread_cond_t cond; |
| 51 | 51 |
| 52 pp::VarDictionary result; | 52 pp::VarDictionary result; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 static std::string GetCwd() { | 55 static std::string GetCwd() { |
| 56 char cwd[PATH_MAX + 1]; | 56 char cwd[PATH_MAX] = "."; |
| 57 // TODO(hamaji): Remove this #if and always call getcwd. | 57 if (!getcwd(cwd, PATH_MAX)) { |
| 58 // https://code.google.com/p/naclports/issues/detail?id=109 | 58 NACL_LOG("getcwd failed: %s\n", strerror(errno)); |
|
binji
2014/12/11 23:19:57
reference this bug?
| |
| 59 #if defined(__GLIBC__) | |
| 60 if (!getwd(cwd)) | |
| 61 #else | |
| 62 if (!getcwd(cwd, PATH_MAX)) | |
| 63 #endif | |
| 64 assert(0); | 59 assert(0); |
| 60 } | |
| 65 return cwd; | 61 return cwd; |
| 66 } | 62 } |
| 67 | 63 |
| 68 static std::string GetAbsPath(const std::string& path) { | 64 static std::string GetAbsPath(const std::string& path) { |
| 69 assert(!path.empty()); | 65 assert(!path.empty()); |
| 70 if (path[0] == '/') | 66 if (path[0] == '/') |
| 71 return path; | 67 return path; |
| 72 else | 68 else |
| 73 return GetCwd() + '/' + path; | 69 return GetCwd() + '/' + path; |
| 74 } | 70 } |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 812 return spawnve_impl(P_OVERLAY, path, argv, envp); | 808 return spawnve_impl(P_OVERLAY, path, argv, envp); |
| 813 } | 809 } |
| 814 | 810 |
| 815 int execlpe(const char *path, const char *arg, ...) { /* char* const envp[] */ | 811 int execlpe(const char *path, const char *arg, ...) { /* char* const envp[] */ |
| 816 VARG_TO_ARGV_ENVP; | 812 VARG_TO_ARGV_ENVP; |
| 817 // TODO(bradnelson): Limit path resolution to 'p' variants. | 813 // TODO(bradnelson): Limit path resolution to 'p' variants. |
| 818 return spawnve_impl(P_OVERLAY, path, argv, envp); | 814 return spawnve_impl(P_OVERLAY, path, argv, envp); |
| 819 } | 815 } |
| 820 | 816 |
| 821 }; // extern "C" | 817 }; // extern "C" |
| OLD | NEW |