Skip to content

Commit 5d7829a

Browse files
committed
fix: respect $WATCHMAN_SOCK env variable for spawned service
1 parent 654a498 commit 5d7829a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

watchman/main.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static SpawnResult spawn_via_launchd() {
545545
"--foreground",
546546
fmt::format("--logfile={}", logging::log_name),
547547
fmt::format("--log-level={}", logging::log_level),
548-
fmt::format("--sockname={}", get_unix_sock_name()),
548+
fmt::format("--unix-listener-path={}", get_unix_sock_name()),
549549
fmt::format("--statefile={}", flags.watchman_state_file),
550550
fmt::format("--pidfile={}", flags.pid_file)};
551551
std::string watchman_spawning_command;
@@ -837,7 +837,19 @@ static void setup_sock_name() {
837837
flags.named_pipe_path = fmt::format("\\\\.\\pipe\\watchman-{}", user);
838838
}
839839
#endif
840-
compute_file_name(flags.unix_sock_name, user, "sock", "sockname");
840+
auto sock = getenv("WATCHMAN_SOCK");
841+
if (sock && flags.unix_sock_name.empty()) {
842+
if (mkdir(dirname(sock), 0700) == 0 || errno == EEXIST) {
843+
flags.unix_sock_name = sock;
844+
} else {
845+
log(FATAL,
846+
"failed to create base directory specified by $WATCHMAN_SOCK: ",
847+
folly::errnoStr(errno),
848+
"\n");
849+
}
850+
} else {
851+
compute_file_name(flags.unix_sock_name, user, "sock", "sockname");
852+
}
841853

842854
compute_file_name(flags.watchman_state_file, user, "state", "statefile");
843855
compute_file_name(

0 commit comments

Comments
 (0)