Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: ports/nacl-spawn/nacl_spawn.cc

Issue 796123002: Fix TODO by removing use of getwd() in nacl-spawn (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698