diff --git a/CMakeLists.txt b/CMakeLists.txt index 8252ba5f1b9d..169d847deade 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -605,6 +605,7 @@ watchman/PerfSample.cpp watchman/fs/ParallelWalk.cpp watchman/fs/Pipe.cpp watchman/ProcessLock.cpp +watchman/ProcessUtil.cpp # PubSub.cpp (in liblog) watchman/QueryableView.cpp watchman/SanityCheck.cpp diff --git a/watchman/Client.cpp b/watchman/Client.cpp index 1cc3d3721577..6c981b3905a1 100644 --- a/watchman/Client.cpp +++ b/watchman/Client.cpp @@ -9,11 +9,13 @@ #include +#include "eden/common/utils/ProcessInfoCache.h" #include "watchman/Command.h" #include "watchman/Errors.h" #include "watchman/Logging.h" #include "watchman/MapUtil.h" #include "watchman/Poison.h" +#include "watchman/ProcessUtil.h" #include "watchman/QueryableView.h" #include "watchman/Shutdown.h" #include "watchman/root/Root.h" @@ -23,17 +25,6 @@ namespace watchman { namespace { -using namespace facebook::eden; - -ProcessInfoCache& getProcessInfoCache() { - static auto* pic = new ProcessInfoCache; - return *pic; -} - -ProcessInfoHandle lookupProcessInfo(pid_t pid) { - return getProcessInfoCache().lookup(pid); -} - constexpr size_t kResponseLogLimit = 0; folly::Synchronized> clients; diff --git a/watchman/ProcessUtil.cpp b/watchman/ProcessUtil.cpp new file mode 100644 index 000000000000..867affcbf9bc --- /dev/null +++ b/watchman/ProcessUtil.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include "watchman/ProcessUtil.h" + +#include "eden/common/utils/ProcessInfoCache.h" + +namespace watchman { + +using namespace facebook::eden; + +namespace { +ProcessInfoCache& getProcessInfoCache() { + static auto* pic = new ProcessInfoCache; + return *pic; +} +} // namespace + +ProcessInfoHandle lookupProcessInfo(pid_t pid) { + return getProcessInfoCache().lookup(pid); +} + +} // namespace watchman diff --git a/watchman/ProcessUtil.h b/watchman/ProcessUtil.h new file mode 100644 index 000000000000..c90a386979f0 --- /dev/null +++ b/watchman/ProcessUtil.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +namespace facebook::eden { +class ProcessInfoHandle; +} + +namespace watchman { + +using ProcessInfoHandle = facebook::eden::ProcessInfoHandle; + +ProcessInfoHandle lookupProcessInfo(pid_t pid); + +} // namespace watchman