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

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

Issue 627103003: Add shared library version of libcli_main Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 6 years, 2 months 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 | « ports/nacl-spawn/nacl_main.h ('k') | ports/nacl-spawn/path_util.h » ('j') | 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 #include "spawn.h" 9 #include "spawn.h"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 struct NaClSpawnReply { 49 struct NaClSpawnReply {
50 pthread_mutex_t mu; 50 pthread_mutex_t mu;
51 pthread_cond_t cond; 51 pthread_cond_t cond;
52 52
53 pp::VarDictionary result; 53 pp::VarDictionary result;
54 }; 54 };
55 55
56 static std::string GetCwd() { 56 static std::string GetCwd() {
57 char cwd[PATH_MAX + 1]; 57 char cwd[PATH_MAX + 1];
58 // TODO(hamaji): Remove this #if and always call getcwd.
59 // https://code.google.com/p/naclports/issues/detail?id=109
60 #if defined(__GLIBC__)
61 if (!getwd(cwd))
62 #else
63 if (!getcwd(cwd, PATH_MAX)) 58 if (!getcwd(cwd, PATH_MAX))
64 #endif
65 assert(0); 59 assert(0);
66 return cwd; 60 return cwd;
67 } 61 }
68 62
69 static std::string GetAbsPath(const std::string& path) { 63 static std::string GetAbsPath(const std::string& path) {
70 assert(!path.empty()); 64 assert(!path.empty());
71 if (path[0] == '/') 65 if (path[0] == '/')
72 return path; 66 return path;
73 else 67 else
74 return GetCwd() + '/' + path; 68 return GetCwd() + '/' + path;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 interpreter = std::string(start, end - start); 275 interpreter = std::string(start, end - start);
282 } 276 }
283 FindInterpreter(&interpreter); 277 FindInterpreter(&interpreter);
284 VarArrayInsert(0, interpreter, &args); 278 VarArrayInsert(0, interpreter, &args);
285 *prog = interpreter; 279 *prog = interpreter;
286 return true; 280 return true;
287 } 281 }
288 282
289 static bool UseBuiltInFallback(std::string* prog, pp::VarDictionary* req) { 283 static bool UseBuiltInFallback(std::string* prog, pp::VarDictionary* req) {
290 if (prog->find('/') == std::string::npos) { 284 if (prog->find('/') == std::string::npos) {
291 bool found = false;
292 const char* path_env = getenv("PATH"); 285 const char* path_env = getenv("PATH");
293 std::vector<std::string> paths; 286 std::vector<std::string> paths;
294 GetPaths(path_env, &paths); 287 GetPaths(path_env, &paths);
295 if (GetFileInPaths(*prog, paths, prog)) { 288 if (GetFileInPaths(*prog, paths, prog)) {
296 // Update argv[0] to match prog if we ended up changing it. 289 // Update argv[0] to match prog if we ended up changing it.
297 pp::Var argsv = req->Get("args"); 290 pp::Var argsv = req->Get("args");
298 assert(argsv.is_array()); 291 assert(argsv.is_array());
299 pp::VarArray args(argsv); 292 pp::VarArray args(argsv);
300 args.Set(0, *prog); 293 args.Set(0, *prog);
301 } else { 294 } else {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 return -1; 615 return -1;
623 } 616 }
624 617
625 pipefd[0] = readSocket; 618 pipefd[0] = readSocket;
626 pipefd[1] = writeSocket; 619 pipefd[1] = writeSocket;
627 620
628 return 0; 621 return 0;
629 } 622 }
630 623
631 }; // extern "C" 624 }; // extern "C"
OLDNEW
« no previous file with comments | « ports/nacl-spawn/nacl_main.h ('k') | ports/nacl-spawn/path_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698