aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2014-12-16 10:30:41 +0100
committerLukas Larsson <[email protected]>2014-12-16 10:30:41 +0100
commitbe779dbb921e2f99d1d6f626d32e34053a0635d9 (patch)
tree30184126e729e4e4779b3e9afdbb7348139a1c4b /erts
parentd5b67726739befc7d0ab9a9282494ae1c28903d7 (diff)
parentb94fe0f28d68747a2e9b78101f91b86b37c8f83b (diff)
downloadotp-be779dbb921e2f99d1d6f626d32e34053a0635d9.tar.gz
otp-be779dbb921e2f99d1d6f626d32e34053a0635d9.tar.bz2
otp-be779dbb921e2f99d1d6f626d32e34053a0635d9.zip
Merge branch 'lukas/erts/non-blocking-shell'
* lukas/erts/non-blocking-shell: erts: Fix big-endian issue with printf_putc
Diffstat (limited to 'erts')
-rw-r--r--erts/lib_src/common/erl_printf.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/erts/lib_src/common/erl_printf.c b/erts/lib_src/common/erl_printf.c
index 0a0346ac2d..a38017b62f 100644
--- a/erts/lib_src/common/erl_printf.c
+++ b/erts/lib_src/common/erl_printf.c
@@ -93,10 +93,12 @@ void (*erts_printf_unblock_fpe)(int) = NULL;
static int
printf_putc(int c, FILE *stream) {
if ((FILE*)stream == stdout || (FILE*)stream == stderr) {
- int fd = stream == stdout ? fileno(stdout) : fileno(stdin);
+ int fd = stream == stdout ? fileno(stdout) : fileno(stderr);
+ /* cast to a char here, because write expects bytes. */
+ unsigned char buf[1] = { c };
int res;
do {
- res = write(fd,&c,1);
+ res = write(fd, buf, 1);
} while (res == -1 && (errno == EAGAIN || errno == EINTR));
if (res == -1) return EOF;
return res;
@@ -109,7 +111,7 @@ static size_t
printf_fwrite(const void *ptr, size_t size, size_t nitems,
FILE *stream) {
if ((FILE*)stream == stdout || (FILE*)stream == stderr) {
- int fd = stream == stdout ? fileno(stdout) : fileno(stdin);
+ int fd = stream == stdout ? fileno(stdout) : fileno(stderr);
int res;
do {
res = write(fd, ptr, size*nitems);