This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: perror() changes the orientation of stderr to byte-oriented mode if stderr is not oriented yet.


Hi Takashi,



again, please send patches related to newlib to the newlib mailing list.
Newlib patches affect more targets than just Cygwin.  I redirected this
mail to the newlib list and attached your original attachments.  Thank
you.



On Jun 27 20:01, Takashi Yano wrote:
> POSIX states:
> The perror() function shall not change the orientation of the standard
> error stream.
> 
> However, cygwin perror() function changes the orientation of stderr to
> byte-oriented mode if stderr is not oriented yet.

That's newlib's perror actually.

> [...]
> I have made a patch to solve this problem, attached. However, I am not
> sure that calling _write_r() here is correct manner. I will appreciate
> if anyone familiar with libc code comment or make suggestions.

I'm not sure exactly.  It may be nice to keep the writes buffered
if the original stderr stream is buffered as well.

What about duplicating the non-_FVWRITE_IN_STREAMIO part of _fputs_r,
just without calling ORIENT?

Another solution might be what glibc does; if the stream has no
orientation yet, it duplicates the stderr FILE handle and uses that to
print the string.

Checking FreeBSD, it seems it actually calls writev, without actually
checking if the entire string has been written, see
https://github.com/freebsd/freebsd/blob/master/lib/libc/stdio/perror.c


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: 0001-Fix-a-bug-of-perror-which-changes-the-orientation-of.patch
Description: Text document

Attachment: chkperror.c
Description: Text document

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]