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

Unified Diff: util/posix/process_util.h

Issue 461253002: Add ProcessArgumentsForPID() (process_util) and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Revise comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | util/posix/process_util_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/posix/process_util.h
diff --git a/util/posix/process_util.h b/util/posix/process_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..0abe46eb34c40c37e1b40df27ceec59a38f0845b
--- /dev/null
+++ b/util/posix/process_util.h
@@ -0,0 +1,42 @@
+// Copyright 2014 The Crashpad Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef CRASHPAD_UTIL_POSIX_PROCESS_UTIL_POSIX_H_
+#define CRASHPAD_UTIL_POSIX_PROCESS_UTIL_POSIX_H_
+
+#include <unistd.h>
+
+#include <string>
+#include <vector>
+
+namespace crashpad {
+
+//! \brief Obtains the arguments used to launch a process.
+//!
+//! \param[in] pid The process ID of the process to examine.
+//! \param[out] argv The process’ arguments as passed to its `main()` function
+//! as the \a argv parameter, possibly modified by the process.
+//!
+//! \return `true` on success, with \a argv populated appropriately. Otherwise,
+//! `false`.
+//!
+//! \note This function may spuriously return `false` when used to examine a
+//! process that it is calling `exec()`. If examining such a process, call
+//! this function in a retry loop with a small (100ns) delay to avoid an
+//! erroneous assumption that \a pid is not running.
+bool ProcessArgumentsForPID(pid_t pid, std::vector<std::string>* argv);
+
+} // namespace crashpad
+
+#endif // CRASHPAD_UTIL_POSIX_PROCESS_UTIL_POSIX_H_
« no previous file with comments | « no previous file | util/posix/process_util_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698