add O_BINARY to all open() calls except tty_fd

cf. http://svn.netlabs.org/libc/wiki/Faq#Whydoesntreadfdbufsize_of_filereturnsize_of_file
This commit is contained in:
tg
2013-10-09 11:59:30 +00:00
parent 7f16464902
commit f920d94785
8 changed files with 28 additions and 21 deletions

View File

@@ -27,7 +27,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.132 2013/09/24 20:19:44 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.133 2013/10/09 11:59:28 tg Exp $");
Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign;
@@ -720,7 +720,8 @@ hist_init(Source *s)
retry:
/* we have a file and are interactive */
if ((fd = open(hname, O_RDWR | O_CREAT | O_APPEND, 0600)) < 0)
if ((fd = open(hname, O_RDWR | O_CREAT | O_APPEND | O_BINARY,
0600)) < 0)
return;
histfd = savefd(fd);
@@ -756,7 +757,7 @@ hist_init(Source *s)
/* create temporary file */
nhname = shf_smprintf("%s.%d", hname, (int)procpid);
if ((fd = open(nhname, O_RDWR | O_CREAT | O_TRUNC |
O_EXCL, 0600)) < 0) {
O_EXCL | O_BINARY, 0600)) < 0) {
/* just don't truncate then, meh. */
goto hist_trunc_dont;
}