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;
-}
-
/*
*----------------------------------------------------------------------
*
- * 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
*/
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);
+}