Thanks to visit codestin.com
Credit goes to chromium.googlesource.com

blob: 88242a2a50674ea827e68662b69d5fb001357d12 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2017 The Chromium Authors
Scott Grahamb4638ab42017-05-24 23:20:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/process/process_handle.h"
6
Wezfaa8f7a2021-05-11 21:10:097#include <lib/zx/process.h>
Scott Grahamfe0e9f462017-09-18 21:25:048#include <zircon/process.h>
Scott Grahamb4638ab42017-05-24 23:20:219
Wezfaa8f7a2021-05-11 21:10:0910#include "base/fuchsia/koid.h"
Scott Grahamb4638ab42017-05-24 23:20:2111#include "base/logging.h"
12
13namespace base {
14
15ProcessId GetCurrentProcId() {
16 return GetProcId(GetCurrentProcessHandle());
17}
18
19ProcessHandle GetCurrentProcessHandle() {
Scott Grahamfe0e9f462017-09-18 21:25:0420 // Note that zx_process_self() returns a real handle, and ownership is not
Scott Grahamb4638ab42017-05-24 23:20:2121 // transferred to the caller (i.e. this should never be closed).
Scott Grahamfe0e9f462017-09-18 21:25:0422 return zx_process_self();
Scott Grahamb4638ab42017-05-24 23:20:2123}
24
25ProcessId GetProcId(ProcessHandle process) {
Wezfaa8f7a2021-05-11 21:10:0926 return GetKoid(*zx::unowned_process(process)).value_or(ZX_KOID_INVALID);
Scott Grahamb4638ab42017-05-24 23:20:2127}
28
29} // namespace base