diff options
author | mike <mike@FreeBSD.org> | 2001-09-25 04:42:40 +0000 |
---|---|---|
committer | mike <mike@FreeBSD.org> | 2001-09-25 04:42:40 +0000 |
commit | 5db0075c3657e42be80e034626b54c3144aa71e4 (patch) | |
tree | d564d875aede991f389a83c55cebd638cb2dc6ff /sys/fs/procfs | |
parent | a3f68a6bffc8444331b209faf58492fa726a4c00 (diff) | |
download | FreeBSD-src-5db0075c3657e42be80e034626b54c3144aa71e4.zip FreeBSD-src-5db0075c3657e42be80e034626b54c3144aa71e4.tar.gz |
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
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r-- | sys/fs/procfs/procfs_status.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index c75294b..1c8b4ca 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -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(); |