Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
8399d035
Commit
8399d035
authored
Aug 23, 2008
by
Andreas Schwab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(procfs_system_process_attributes): Fix portability
problems.
parent
069e777d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
14 deletions
+26
-14
src/ChangeLog
src/ChangeLog
+5
-0
src/process.c
src/process.c
+21
-14
No files found.
src/ChangeLog
View file @
8399d035
2008-08-23 Andreas Schwab <schwab@suse.de>
* process.c (procfs_system_process_attributes): Fix use of
uninitialized variables.
2008-08-23 Eli Zaretskii <eliz@gnu.org>
* emacs.c (main) [MSDOS]: Call syms_of_xmenu.
...
...
src/process.c
View file @
8399d035
...
...
@@ -7246,10 +7246,10 @@ procfs_system_process_attributes (pid)
char procbuf[1025], *p, *q;
int fd;
ssize_t nread;
char cmd
[PATH_MAX]
;
const
char
*
cmd;
char *cmdline = NULL;
size_t cmdsize;
int
c;
unsigned char
c;
int proc_id, ppid, uid, gid, pgrp, sess, tty, tpgid, thcount;
unsigned long long utime, stime, cutime, cstime, start;
long priority, nice, rss;
...
...
@@ -7277,7 +7277,7 @@ procfs_system_process_attributes (pid)
uid_eint = uid;
attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid_eint)), attrs);
BLOCK_INPUT;
pw =
(struct passwd *)
getpwuid (uid);
pw = getpwuid (uid);
UNBLOCK_INPUT;
if (pw)
attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs);
...
...
@@ -7286,7 +7286,7 @@ procfs_system_process_attributes (pid)
gid_eint = gid;
attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid_eint)), attrs);
BLOCK_INPUT;
gr =
(struct group *)
getgrgid (gid);
gr = getgrgid (gid);
UNBLOCK_INPUT;
if (gr)
attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
...
...
@@ -7300,18 +7300,25 @@ procfs_system_process_attributes (pid)
procbuf[nread] = '\0';
p = procbuf;
p = strchr (p, '(') + 1;
q = strchr (p, ')');
/* comm */
if (q > p)
cmd = NULL;
p = strchr (p, '(');
if (p != NULL)
{
memcpy (cmd, p, q - p);
cmd[q - p] = '\0';
q = strrchr (p + 1, ')');
/* comm */
if (q != NULL)
{
cmd = p + 1;
cmdsize = q - cmd;
}
}
if (cmd == NULL)
{
cmd = "???";
cmdsize = 3;
}
else
strcpy (cmd, "???");
/* Command name is encoded in locale-coding-system; decode it. */
cmd_str = make_unibyte_string (cmd,
q ? q - p : 3
);
cmd_str = make_unibyte_string (cmd,
cmdsize
);
decoded_cmd = code_convert_string_norecord (cmd_str,
Vlocale_coding_system, 0);
attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs);
...
...
@@ -7412,7 +7419,7 @@ procfs_system_process_attributes (pid)
fd = emacs_open (fn, O_RDONLY, 0);
if (fd >= 0)
{
for (cmdsize = 0; emacs_read (fd,
(char *)
&c, 1) == 1; cmdsize++)
for (cmdsize = 0; emacs_read (fd, &c, 1) == 1; cmdsize++)
{
if (isspace (c) || c == '\\')
cmdsize++; /* for later quoting, see below */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment