1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

A process name may contain whitespace and unprintable characters,

so convert those characters to octal notation.  Also convert
backslashes to octal notation to avoid confusion.

Reviewed by:	des
MFC after:	1 week
This commit is contained in:
Mike Barcroft 2001-09-25 04:42:40 +00:00
parent 9ba6d8e420
commit 3273a63ed9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=83920

View File

@ -69,7 +69,7 @@ procfs_dostatus(curp, p, pfs, uio)
struct session *sess;
struct tty *tp;
struct ucred *cr;
char *ps;
char *ps, *pc;
char *sep;
int pid, ppid, pgid, sid;
int i;
@ -95,10 +95,16 @@ procfs_dostatus(curp, p, pfs, uio)
("Too short buffer for new MAXCOMLEN"));
ps = psbuf;
bcopy(p->p_comm, ps, MAXCOMLEN);
ps[MAXCOMLEN] = '\0';
ps += strlen(ps);
DOCHECK();
pc = p->p_comm;
xlen = strlen(p->p_comm);
do {
if (*pc < 33 || *pc > 126 || *pc == '\\')
ps += snprintf(ps, psbuf + sizeof(psbuf) - ps, "\\%03o",
*pc);
else
*ps++ = *pc;
DOCHECK();
} while (++pc < p->p_comm + xlen);
ps += snprintf(ps, psbuf + sizeof(psbuf) - ps,
" %d %d %d %d ", pid, ppid, pgid, sid);
DOCHECK();