From: John Wolfe Date: Thu, 8 Sep 2022 21:51:39 +0000 (-0700) Subject: Move HostinfoProcessQuery() from hostinfo.c into hostinfoPosix.c. X-Git-Tag: stable-12.2.0~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a8bcb4ad1773fd62ad5a8bee352bf6ed34946a6;p=thirdparty%2Fopen-vm-tools.git Move HostinfoProcessQuery() from hostinfo.c into hostinfoPosix.c. --- diff --git a/open-vm-tools/lib/misc/hostinfo.c b/open-vm-tools/lib/misc/hostinfo.c index c0fe3fd2f..57db878d7 100644 --- a/open-vm-tools/lib/misc/hostinfo.c +++ b/open-vm-tools/lib/misc/hostinfo.c @@ -335,41 +335,3 @@ Hostinfo_GetOSDetailedData(void) return detailedData; } - -/* - *---------------------------------------------------------------------- - * - * Hostinfo_QueryProcessExistence -- - * - * Determine if a PID is "alive" or "dead". Failing to be able to - * do this perfectly, do not make any assumption - say the answer - * is unknown. - * - * Results: - * HOSTINFO_PROCESS_QUERY_ALIVE Process is alive - * HOSTINFO_PROCESS_QUERY_DEAD Process is dead - * HOSTINFO_PROCESS_QUERY_UNKNOWN Don't know - * - * Side effects: - * None - * - *---------------------------------------------------------------------- - */ - -HostinfoProcessQuery -Hostinfo_QueryProcessExistence(int pid) // IN: -{ - HostinfoProcessQuery ret; - HostinfoProcessSnapshot *s = Hostinfo_AcquireProcessSnapshot(); - - if (s == NULL) { - return HOSTINFO_PROCESS_QUERY_UNKNOWN; - } - - ret = Hostinfo_QueryProcessSnapshot(s, pid); - - Hostinfo_ReleaseProcessSnapshot(s); - - return ret; -} - diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index f525236f3..72fdd18b4 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -4452,11 +4452,11 @@ Hostinfo_ReleaseProcessSnapshot(HostinfoProcessSnapshot *s) // IN/OPT: /* *---------------------------------------------------------------------- * - * Hostinfo_QueryProcessSnapshot -- + * Hostinfo_QueryProcessExistence -- * - * Determine if a PID is "alive" or "dead" within the specified - * process snapshot. Failing to be able to do this perfectly, - * do not make any assumption - say the answer is unknown. + * Determine if a PID is "alive" or "dead". Failing to be able to + * do this perfectly, do not make any assumption - say the answer + * is unknown. * * Results: * HOSTINFO_PROCESS_QUERY_ALIVE Process is alive @@ -4470,26 +4470,54 @@ Hostinfo_ReleaseProcessSnapshot(HostinfoProcessSnapshot *s) // IN/OPT: */ HostinfoProcessQuery -Hostinfo_QueryProcessSnapshot(HostinfoProcessSnapshot *s, // IN: - int pid) // IN: +Hostinfo_QueryProcessExistence(int pid) // IN: { - HostinfoProcessQuery ret; - - ASSERT(s != NULL); + HostinfoProcessQuery result; switch ((kill(pid, 0) == -1) ? errno : 0) { case 0: case EPERM: - ret = HOSTINFO_PROCESS_QUERY_ALIVE; + result = HOSTINFO_PROCESS_QUERY_ALIVE; break; + case ESRCH: - ret = HOSTINFO_PROCESS_QUERY_DEAD; + result = HOSTINFO_PROCESS_QUERY_DEAD; break; + default: - ret = HOSTINFO_PROCESS_QUERY_UNKNOWN; + result = HOSTINFO_PROCESS_QUERY_UNKNOWN; break; } - return ret; + return result; } + +/* + *---------------------------------------------------------------------- + * + * Hostinfo_QueryProcessSnapshot -- + * + * Determine if a PID is "alive" or "dead" within the specified + * process snapshot. Failing to be able to do this perfectly, + * do not make any assumption - say the answer is unknown. + * + * Results: + * HOSTINFO_PROCESS_QUERY_ALIVE Process is alive + * HOSTINFO_PROCESS_QUERY_DEAD Process is dead + * HOSTINFO_PROCESS_QUERY_UNKNOWN Don't know + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +HostinfoProcessQuery +Hostinfo_QueryProcessSnapshot(HostinfoProcessSnapshot *s, // IN: + int pid) // IN: +{ + ASSERT(s != NULL); + + return Hostinfo_QueryProcessExistence(pid); +}