]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Change to common source files not applicable to open-vm-tools.
authorKaty Feng <fkaty@vmware.com>
Mon, 6 Mar 2023 18:32:39 +0000 (10:32 -0800)
committerKaty Feng <fkaty@vmware.com>
Mon, 6 Mar 2023 18:32:39 +0000 (10:32 -0800)
open-vm-tools/lib/include/hostinfo.h
open-vm-tools/lib/misc/hostinfoPosix.c

index 05f2ef5ded12e5ccc8c6bce48fced7df59593a85..4e409c1bda492349b45c75b621ed02a56a24e75a 100644 (file)
@@ -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
index e1e1f5d3cd164acda470a8e8e1ea3d436ddad93f..f3aef07845cab2d3f96d1ecc95d5ddbd092c37c7 100644 (file)
@@ -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
 #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
+}
+
+
 /*
  *----------------------------------------------------------------------
  *