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

Takashi Yano takashi.yano@nifty.ne.jp
Wed Jun 27 16:45:00 GMT 2018


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.

Simple test case (chkperror.c) attached checks this behavior.

Expected result:
0
äöü: Invalid argument
0
äöü
1
äöü: Invalid argument

However, cygwin result:
0
äöü: Invalid argument
-1
â–’â–’â–’
-1
äöü: Invalid argument

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.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-a-bug-of-perror-which-changes-the-orientation-of.patch
Type: application/octet-stream
Size: 1690 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20180627/97daf6c9/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chkperror.c
Type: text/x-csrc
Size: 334 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20180627/97daf6c9/attachment.bin>
-------------- next part --------------

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list