From: Eli Zaretskii Date: Fri, 19 Sep 2008 17:21:16 +0000 (+0000) Subject: (procfs_system_process_attributes): Fix cmdline in case /proc/PID/cmdline X-Git-Tag: emacs-pretest-23.0.90~2843 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a1e422f32d3adb6fed846dbcdbcc26072b8e7530;p=emacs.git (procfs_system_process_attributes): Fix cmdline in case /proc/PID/cmdline is empty. --- diff --git a/src/ChangeLog b/src/ChangeLog index cf29620c36b..8b8d487c0f7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2008-09-19 Eli Zaretskii + * process.c (procfs_system_process_attributes): Fix cmdline in + case /proc/PID/cmdline is empty. + * xterm.c (x_wm_set_size_hint): Use x_display_pixel_width and x_display_pixel_height. diff --git a/src/process.c b/src/process.c index 80a657b2eda..75f36c5fce9 100644 --- a/src/process.c +++ b/src/process.c @@ -7419,17 +7419,17 @@ procfs_system_process_attributes (pid) fd = emacs_open (fn, O_RDONLY, 0); if (fd >= 0) { - for (cmdsize = 0; emacs_read (fd, &c, 1) == 1; cmdsize++) + for (cmdline_size = 0; emacs_read (fd, &c, 1) == 1; cmdline_size++) { if (isspace (c) || c == '\\') - cmdsize++; /* for later quoting, see below */ + cmdline_size++; /* for later quoting, see below */ } - if (cmdsize) + if (cmdline_size) { - cmdline = xmalloc (cmdsize + 1); + cmdline = xmalloc (cmdline_size + 1); lseek (fd, 0L, SEEK_SET); cmdline[0] = '\0'; - if ((nread = read (fd, cmdline, cmdsize)) >= 0) + if ((nread = read (fd, cmdline, cmdline_size)) >= 0) cmdline[nread++] = '\0'; /* We don't want trailing null characters. */ for (p = cmdline + nread - 1; p > cmdline && !*p; p--) @@ -7446,18 +7446,18 @@ procfs_system_process_attributes (pid) else if (*p == '\0') *p = ' '; } - cmdsize = nread; + cmdline_size = nread; } else { - cmdsize = strlen (cmd) + 2; - cmdline = xmalloc (cmdsize + 1); + cmdline_size = cmdsize + 2; + cmdline = xmalloc (cmdline_size + 1); strcpy (cmdline, "["); - strcat (strcat (cmdline, cmd), "]"); + strcat (strncat (cmdline, cmd, cmdsize), "]"); } emacs_close (fd); /* Command line is encoded in locale-coding-system; decode it. */ - cmd_str = make_unibyte_string (cmdline, cmdsize); + cmd_str = make_unibyte_string (cmdline, cmdline_size); decoded_cmd = code_convert_string_norecord (cmd_str, Vlocale_coding_system, 0); xfree (cmdline);