aboutsummaryrefslogtreecommitdiff
path: root/libio/stdio/setfileno.c
diff options
context:
space:
mode:
Diffstat (limited to 'libio/stdio/setfileno.c')
-rw-r--r--libio/stdio/setfileno.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libio/stdio/setfileno.c b/libio/stdio/setfileno.c
new file mode 100644
index 00000000000..f7ccc6fdd66
--- /dev/null
+++ b/libio/stdio/setfileno.c
@@ -0,0 +1,17 @@
+/* Some known programs (xterm, pdksh?) non-portably change the _file
+ field of s struct _iobuf. This kludge allows the same "functionality".
+ This code is an undocumented feature for iostream/stdio. Use it at
+ your own risk. */
+
+#include "libioP.h"
+#include "stdio.h"
+
+void
+setfileno(fp, fd)
+ _IO_FILE* fp;
+ int fd;
+{
+ CHECK_FILE(fp, );
+ if ((fp->_flags & _IO_IS_FILEBUF) != 0)
+ fp->_fileno = fd;
+}