Subject: Re: bug#36279: 26.2.90; (process-attributes nonexistent-pid) segmentation fault

From: Eli Zaretskii <[email-masked]>
Date: Tue, 18 Jun 2019 20:44:41 +0300

> Date: Wed, 19 Jun 2019 00:23:20 +0800
> From: xuchunyang <[email-masked]>
> Cc: [email-masked], Noam Postavsky <[email-masked]>
> 
> It fixes the issue for me too. (process-attributes 123456) returns nil instead of crashing Emacs.
> 
> > 
> > diff --git a/src/sysdep.c b/src/sysdep.c
> > index 1e35e06b63..518ecebcf6 100644
> > --- a/src/sysdep.c
> > +++ b/src/sysdep.c
> > @@ -3798,7 +3798,7 @@ system_process_attributes (Lisp_Object pid)
> >    CONS_TO_INTEGER (pid, int, proc_id);
> >    mib[3] = proc_id;
> >  
> > -  if (sysctl (mib, 4, &proc, &proclen, NULL, 0) != 0)
> > +  if (sysctl (mib, 4, &proc, &proclen, NULL, 0) != 0 || proclen == 0)
> >      return attrs;
> >  
> >    uid = proc.kp_eproc.e_ucred.cr_uid;
> >

Thanks.  Robert, please push to the emacs-26 branch.

(I understand this problem is quite old, is that right?)