about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--include/stropts.h3
-rw-r--r--src/misc/isastream.c7
2 files changed, 9 insertions, 1 deletions
diff --git a/include/stropts.h b/include/stropts.h
index 36d84bbb..c99c922e 100644
--- a/include/stropts.h
+++ b/include/stropts.h
@@ -129,7 +129,8 @@ struct str_list {
 	struct str_mlist *sl_modlist;
 };
 
-int ioctl (int, int, ...);
+int isastream(int);
+int ioctl(int, int, ...);
 
 #ifdef __cplusplus
 }
diff --git a/src/misc/isastream.c b/src/misc/isastream.c
new file mode 100644
index 00000000..4dafdb08
--- /dev/null
+++ b/src/misc/isastream.c
@@ -0,0 +1,7 @@
+#include <stropts.h>
+#include <fcntl.h>
+
+int isastream(int fd)
+{
+	return fcntl(fd, F_GETFD) < 0 ? -1 : 0;
+}