Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section

*** 25,35 **** * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* ! * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ --- 25,35 ---- * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* ! * Copyright (c) 2018, Joyent, Inc. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */
*** 106,115 **** --- 106,116 ---- F_PPID, /* parent process id */ F_PGID, /* process group id */ F_SID, /* session id */ F_PSR, /* bound processor */ F_LWP, /* lwp-id */ + F_LWPNAME, /* lwp name */ F_NLWP, /* number of lwps */ F_OPRI, /* old priority (obsolete) */ F_PRI, /* new priority */ F_F, /* process flags */ F_S, /* letter indicating the state */
*** 175,184 **** --- 176,186 ---- { "ppid", "PPID", 5, 5 }, { "pgid", "PGID", 5, 5 }, { "sid", "SID", 5, 5 }, { "psr", "PSR", 3, 2 }, { "lwp", "LWP", 6, 2 }, + { "lwpname", "LWPNAME", 32, 8 }, { "nlwp", "NLWP", 4, 2 }, { "opri", "PRI", 3, 2 }, { "pri", "PRI", 3, 2 }, { "f", "F", 2, 2 }, { "s", "S", 1, 1 },
*** 801,810 **** --- 803,813 ---- switch (f->fname) { case F_TTY: (void) printf("%-*s", f->width, f->header); break; + case F_LWPNAME: case F_FNAME: case F_COMM: case F_ARGS: /* * Print these headers full width
*** 1176,1186 **** header++; } } for (df = &fname[0]; df < &fname[NFIELDS]; df++) if (strcmp(name, df->fname) == 0) { ! if (strcmp(name, "lwp") == 0) Lflg++; break; } if (df >= &fname[NFIELDS]) { (void) fprintf(stderr, --- 1179,1190 ---- header++; } } for (df = &fname[0]; df < &fname[NFIELDS]; df++) if (strcmp(name, df->fname) == 0) { ! if (strcmp(name, "lwp") == 0 || ! strcmp(name, "lwpname") == 0) Lflg++; break; } if (df >= &fname[NFIELDS]) { (void) fprintf(stderr,
*** 1752,1761 **** --- 1756,1786 ---- (void) printf("%*d", width, psinfo->pr_lwp.pr_bindpro); break; case F_LWP: (void) printf("%*d", width, (int)psinfo->pr_lwp.pr_lwpid); break; + case F_LWPNAME: { + char lwpname[THREAD_NAME_MAX] = ""; + char *path = NULL; + int fd; + + if (asprintf(&path, "%s/%d/lwp/%d/lwpname", procdir, + (int)psinfo->pr_pid, (int)psinfo->pr_lwp.pr_lwpid) != -1 && + (fd = open(path, O_RDONLY)) != -1) { + (void) read(fd, lwpname, sizeof (lwpname)); + lwpname[THREAD_NAME_MAX - 1] = '\0'; + (void) close(fd); + } + + free(path); + + if (f->next != NULL) + (void) printf("%-*s", width, lwpname); + else + (void) printf("%s", lwpname); + break; + } case F_NLWP: (void) printf("%*d", width, psinfo->pr_nlwp + psinfo->pr_nzomb); break; case F_OPRI: if (zombie_lwp)