Skip to content

Commit

Permalink
move the method to look up process to a common place
Browse files Browse the repository at this point in the history
Summary: As title in the task, I need to look up process info using this method. Move it to shared util class so that I can include them else where

Reviewed By: kmancini

Differential Revision: D49654377

fbshipit-source-id: d071926d023ef3a8cf2c92e1a328e4db11961bc5
  • Loading branch information
Xinyi Wang authored and facebook-github-bot committed Sep 27, 2023
1 parent a5aee68 commit 5f6d432
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 11 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions watchman/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

#include <folly/MapUtil.h>

#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"
Expand All @@ -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<std::unordered_set<UserClient*>> clients;
Expand Down
27 changes: 27 additions & 0 deletions watchman/ProcessUtil.cpp
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions watchman/ProcessUtil.h
Original file line number Diff line number Diff line change
@@ -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 <folly/portability/SysTypes.h>

namespace facebook::eden {
class ProcessInfoHandle;
}

namespace watchman {

using ProcessInfoHandle = facebook::eden::ProcessInfoHandle;

ProcessInfoHandle lookupProcessInfo(pid_t pid);

} // namespace watchman

0 comments on commit 5f6d432

Please sign in to comment.