From: Katy Feng Date: Mon, 6 Mar 2023 18:32:39 +0000 (-0800) Subject: Change to common source files not applicable to open-vm-tools. X-Git-Tag: stable-12.3.0~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b822932f2b0ea864fdc85005e6ed7bf34c4b2a75;p=thirdparty%2Fopen-vm-tools.git Change to common source files not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/hostinfo.h b/open-vm-tools/lib/include/hostinfo.h index 05f2ef5de..4e409c1bd 100644 --- a/open-vm-tools/lib/include/hostinfo.h +++ b/open-vm-tools/lib/include/hostinfo.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2022 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -57,6 +57,7 @@ HostinfoProcessQuery Hostinfo_QueryProcessSnapshot(HostinfoProcessSnapshot *s, int pid); HostinfoProcessQuery Hostinfo_QueryProcessExistence(int pid); +HostinfoProcessQuery Hostinfo_QueryProcessReaped(int pid); /* This macro defines the current version of the structured header. */ #define HOSTINFO_STRUCT_HEADER_VERSION 1 diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index e1e1f5d3c..f3aef0784 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2022 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -133,6 +133,7 @@ #include "uwvmkAPI.h" #include "uwvmk.h" #include "vmkSyscall.h" +#include "uwvmkprivate.h" #endif #define LGPFX "HOSTINFO:" @@ -4553,6 +4554,62 @@ Hostinfo_QueryProcessExistence(int pid) // IN: } +/* + *---------------------------------------------------------------------- + * + * Hostinfo_QueryProcessReaped -- + * + * Determine if the resources of a "dead" process have been reclaimed. + * On Linux, this is equivalent to querying the process's existence. + * On ESX, we can query the vmkernel. + * + * Results: + * HOSTINFO_PROCESS_QUERY_ALIVE Process is not yet reaped + * HOSTINFO_PROCESS_QUERY_DEAD Process has been reaped + * HOSTINFO_PROCESS_QUERY_UNKNOWN Don't know + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +HostinfoProcessQuery +Hostinfo_QueryProcessReaped(int pid) // IN: +{ +#if defined(VMX86_SERVER) || defined(USERWORLD) // ESXi + VMK_ReturnStatus status = VMKPrivate_WaitForWorldDeath(pid, 1); + HostinfoProcessQuery result; + + switch (status) { + case VMK_TIMEOUT: + result = HOSTINFO_PROCESS_QUERY_ALIVE; + break; + + /* + * VMK_BAD_PARAM indicates the pid is no longer associated with + * a userworld. + * + * VMK_OK indicates the pid has been reaped. + */ + case VMK_BAD_PARAM: + case VMK_OK: + result = HOSTINFO_PROCESS_QUERY_DEAD; + break; + + /* VMK_DEATH_PENDING (on caller), VMK_WAIT_INTERRUPTED */ + default: + result = HOSTINFO_PROCESS_QUERY_UNKNOWN; + break; + } + + return result; +#else + return Hostinfo_QueryProcessExistence(pid); +#endif +} + + /* *---------------------------------------------------------------------- *