Subject: bug#55153: 29.0.50; Implement system_process_attributes on Cygwin

From: Eli Zaretskii <[email-masked]>
Date: Wed, 27 Apr 2022 18:52:58 +0300

> Date: Wed, 27 Apr 2022 11:16:46 -0400
> From: Ken Brown <[email-masked]>
> 
> +# ifdef CYGWIN
> +  /* ttname */
> +  strcpy (procfn_end, "/ctty");
> +  fd = emacs_open (fn, O_RDONLY, 0);
> +  if (fd < 0)
> +    nread = 0;
> +  else
> +    {
> +      record_unwind_protect_int (close_file_unwind, fd);
> +      nread = emacs_read_quit (fd, procbuf, sizeof procbuf);
> +    }
> +  /* /proc/<pid>/ctty should always end in newline. */
> +  if (0 < nread && procbuf[nread - 1] == '\n')
> +    procbuf[nread - 1] = '\0';
> +  else
> +    procbuf[0] = '\0';
> +  attrs = Fcons (Fcons (Qttname, build_string (procbuf)), attrs);

Is what you read from /proc/<pid>/ctty guaranteed to be pure-ASCII
string?  If not, build_string is not the best idea here; you need to
produce a unibyte string and decode it.

Thanks.

P.S. Doesn't this warrant a NEWS entry?