diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-12-28 01:12:59 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-12-28 01:13:21 +0200 |
commit | 2c1620ce1fe3bb2d011ccaca701191927f1d49d6 (patch) | |
tree | b2e7a03df7bf98941ac8b24f4ec43339a0157146 /unix/file.c | |
parent | 3ea03a118880c9ffb6714049c0907a94b39d31a8 (diff) | |
download | micropython-2c1620ce1fe3bb2d011ccaca701191927f1d49d6.tar.gz micropython-2c1620ce1fe3bb2d011ccaca701191927f1d49d6.zip |
unix: Implement uos.dupterm(). Conditional on MICROPY_PY_OS_DUPTERM.
Diffstat (limited to 'unix/file.c')
-rw-r--r-- | unix/file.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/unix/file.c b/unix/file.c index 448cd50edc..7f113d6712 100644 --- a/unix/file.c +++ b/unix/file.c @@ -35,6 +35,7 @@ #include "py/runtime.h" #include "py/stream.h" #include "py/builtin.h" +#include "py/mphal.h" #if MICROPY_PY_IO @@ -80,6 +81,12 @@ STATIC mp_uint_t fdfile_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errc STATIC mp_uint_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) { mp_obj_fdfile_t *o = MP_OBJ_TO_PTR(o_in); check_fd_is_open(o); + #if MICROPY_PY_OS_DUPTERM + if (o->fd <= STDERR_FILENO) { + mp_hal_stdout_tx_strn(buf, size); + return size; + } + #endif mp_int_t r = write(o->fd, buf, size); if (r == -1) { *errcode = errno; |