Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section
@@ -22,11 +22,11 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright 2018 Joyent, Inc.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/types.h>
#include <sys/uio.h>
@@ -350,10 +350,42 @@
}
return (-1);
}
+int
+Plwp_getname(struct ps_prochandle *P, lwpid_t lwpid,
+ char *buf, size_t bufsize)
+{
+ char lwpname[THREAD_NAME_MAX];
+ char *from = NULL;
+ lwp_info_t *lwp;
+
+ if (P->state == PS_IDLE) {
+ errno = ENODATA;
+ return (-1);
+ }
+
+ if (P->state != PS_DEAD) {
+ if (getlwpfile(P, lwpid, "lwpname",
+ lwpname, sizeof (lwpname)) != 0)
+ return (-1);
+ from = lwpname;
+ } else {
+ if ((lwp = getlwpcore(P, lwpid)) == NULL)
+ return (-1);
+ from = lwp->lwp_name;
+ }
+
+ if (strlcpy(buf, from, bufsize) >= bufsize) {
+ errno = ENAMETOOLONG;
+ return (-1);
+ }
+
+ return (0);
+}
+
int
Plwp_getspymaster(struct ps_prochandle *P, lwpid_t lwpid, psinfo_t *ps)
{
lwpstatus_t lps;