summaryrefslogtreecommitdiff
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorRobert Pluim <rpluim@gmail.com>2020-08-18 20:31:37 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-08-18 20:31:42 +0200
commitb4f05274c7a8facbf2a817ec14d234605959c4de (patch)
treefdfe5c9739b74da0e9d6dc959d008b5fc09d0020 /src/sysdep.c
parentc70b5e8ad005d881506b7394d70b45825c036ea0 (diff)
downloademacs-b4f05274c7a8facbf2a817ec14d234605959c4de.tar.gz
Fix truncated command names in process-attributes under Macos
* src/sysdep.c (system_process_attributes): Fix truncation of command names in process-attributes under Macos (bug#36287).
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index b1371cd411b..a1050c4309a 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -53,6 +53,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
# include <sys/sysctl.h>
#endif
+#ifdef DARWIN_OS
+# include <libproc.h>
+#endif
+
#ifdef __FreeBSD__
/* Sparc/ARM machine/frame.h has 'struct frame' which conflicts with Emacs's
'struct frame', so rename it. */
@@ -3871,8 +3875,21 @@ system_process_attributes (Lisp_Object pid)
if (gr)
attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
+ char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
+ char *comm;
+
+ if (proc_pidpath (proc_id, pathbuf, sizeof(pathbuf)) > 0)
+ {
+ if ((comm = strrchr (pathbuf, '/')))
+ comm++;
+ else
+ comm = pathbuf;
+ }
+ else
+ comm = proc.kp_proc.p_comm;
+
decoded_comm = (code_convert_string_norecord
- (build_unibyte_string (proc.kp_proc.p_comm),
+ (build_unibyte_string (comm),
Vlocale_coding_system, 0));
attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs);