Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/cpp_rpc/rpc_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ int mkdir(const char* path, int /* ignored */) { return _mkdir(path); }
#include <iostream>
#include <string>
#include <vector>

#include "../../src/support/utils.h"
#include "rpc_env.h"

Expand Down Expand Up @@ -95,7 +96,16 @@ RPCEnv::RPCEnv(const std::string& wd) {
auto cmdline = fopen("/proc/self/cmdline", "r");
fread(cwd, 1, sizeof(cwd), cmdline);
fclose(cmdline);
base_ = "/data/data/" + std::string(cwd) + "/cache/rpc";
std::string android_base_ = "/data/data/" + std::string(cwd) + "/cache";
struct stat statbuf;
// Check if application data directory exist. If not exist, usually means we run tvm_rpc from
// adb shell terminal.
if (stat(android_base_.data(), &statbuf) == -1 || !S_ISDIR(statbuf.st_mode)) {
// Tmp directory is always writable for 'shell' user.
android_base_ = "/data/local/tmp";
}
base_ = android_base_ + "/rpc";

#elif !defined(_WIN32)
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd))) {
Expand Down
2 changes: 1 addition & 1 deletion apps/cpp_rpc/rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class RPCServer {
auto pid = fork();
if (pid == 0) {
ServerLoopProc(conn, addr, work_dir_);
exit(0);
_exit(0);
}
// Wait for the result
int status = 0;
Expand Down