summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason King <jason.king@joyent.com>2018-09-15 21:46:22 +0000
committerJason King <jason.king@joyent.com>2019-02-23 18:33:58 +0000
commit540be08e437ce290999b29a244386a4283dca907 (patch)
treec3f710095360acd1f95fb94adeb141d6a9374a87
parent9b2ce9c90f656792c9d27ec8cbcec521f3f8922f (diff)
downloadillumos-joyent-540be08e437ce290999b29a244386a4283dca907.tar.gz
OS-2825 process erroneously shows up from 1970
Reviewed by: Mike Gerdts <mike.gerdts@joyent.com> Approved by: Joshua M. Clulow <jmc@joyent.com>
-rw-r--r--usr/src/cmd/svc/svcs/Makefile6
-rw-r--r--usr/src/cmd/svc/svcs/svcs.c37
2 files changed, 14 insertions, 29 deletions
diff --git a/usr/src/cmd/svc/svcs/Makefile b/usr/src/cmd/svc/svcs/Makefile
index 2ea89818c0..36bd39d567 100644
--- a/usr/src/cmd/svc/svcs/Makefile
+++ b/usr/src/cmd/svc/svcs/Makefile
@@ -21,20 +21,20 @@
#
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
#
-# Copyright (c) 2011, Joyent, Inc. All rights reserved.
+# Copyright (c) 2019, Joyent, Inc. All rights reserved.
#
PROG = svcs
OBJS = svcs.o explain.o
MYOBJS = notify_params.o
SRCS = $(OBJS:%.o=%.c) $(MYOBJS:%.o=../common/%.c)
-POFILES = $(OBJS:.o=.po)
+POFILES = $(OBJS:.o=.po)
include ../../Makefile.cmd
include ../../Makefile.ctf
POFILE = $(PROG)_all.po
-LDLIBS += -lcontract -lscf -luutil -lumem -lnvpair -lzonecfg -lsasl
+LDLIBS += -lcontract -lscf -luutil -lumem -lnvpair -lzonecfg -lsasl -lproc
CPPFLAGS += -I ../common
lint := LINTFLAGS = -mux
diff --git a/usr/src/cmd/svc/svcs/svcs.c b/usr/src/cmd/svc/svcs/svcs.c
index 39caabb7d5..8b322a823e 100644
--- a/usr/src/cmd/svc/svcs/svcs.c
+++ b/usr/src/cmd/svc/svcs/svcs.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2019, Joyent, Inc. All rights reserved.
* Copyright (c) 2015, 2016 by Delphix. All rights reserved.
*/
@@ -72,8 +72,8 @@
#include <libscf_priv.h>
#include <libuutil.h>
#include <libnvpair.h>
+#include <libproc.h>
#include <locale.h>
-#include <procfs.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -92,6 +92,13 @@
#define EMPTY_OK 0x01
#define MULTI_OK 0x02
+/*
+ * Per proc(4) when pr_nlwp, pr_nzomb, and pr_lwp.pr_lwpid are all 0,
+ * the process is a zombie.
+ */
+#define IS_ZOMBIE(_psip) \
+ ((_psip)->pr_nlwp == 0 && (_psip)->pr_nzomb == 0 && \
+ (_psip)->pr_lwp.pr_lwpid == 0)
/*
* An AVL-storable node for output lines and the keys to sort them by.
@@ -961,28 +968,6 @@ instance_processes(scf_instance_t *inst, const char *fmri,
return (ret);
}
-static int
-get_psinfo(pid_t pid, psinfo_t *psip)
-{
- char path[100];
- int fd;
-
- (void) snprintf(path, sizeof (path), "/proc/%lu/psinfo", pid);
-
- fd = open64(path, O_RDONLY);
- if (fd < 0)
- return (-1);
-
- if (read(fd, psip, sizeof (*psip)) < 0)
- uu_die(gettext("Could not read info for process %lu"), pid);
-
- (void) close(fd);
-
- return (0);
-}
-
-
-
/*
* Column sprint and sortkey functions
*/
@@ -2079,7 +2064,7 @@ detailed_list_processes(scf_walkinfo_t *wip)
(void) printf("%-*s%lu", DETAILED_WIDTH, gettext("process"),
pids[i]);
- if (get_psinfo(pids[i], &psi) == 0)
+ if (proc_get_psinfo(pids[i], &psi) == 0 && !IS_ZOMBIE(&psi))
(void) printf(" %.*s", PRARGSZ, psi.pr_psargs);
(void) putchar('\n');
@@ -2955,7 +2940,7 @@ add_processes(scf_walkinfo_t *wip, char *line, scf_propertygroup_t *lpg)
struct tm *tm;
int len = 1 + 15 + 8 + 3 + 6 + 1 + PRFNSZ;
- if (get_psinfo(pids[i], &psi) != 0)
+ if (proc_get_psinfo(pids[i], &psi) != 0 || IS_ZOMBIE(&psi))
continue;
line = realloc(line, strlen(line) + len);