From a48308701a4d89d7cc0d0557cfabaec94a0bb3b0 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Mon, 26 Oct 2009 23:27:08 +0100 Subject: add and use xopen_nonblocking (-18b) Signed-off-by: Bernhard Reutner-Fischer Signed-off-by: Denys Vlasenko --- libbb/xfuncs_printf.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libbb/xfuncs_printf.c') diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 345c84219..241887ace 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -140,6 +140,15 @@ int FAST_FUNC xopen(const char *pathname, int flags) return xopen3(pathname, flags, 0666); } +/* Die if we can't open an existing file readonly with O_NONBLOCK + * and return the fd. + * Note that for ioctl O_RDONLY is sufficient. + */ +int FAST_FUNC xopen_nonblocking(const char *pathname) +{ + return xopen(pathname, O_RDONLY | O_NONBLOCK); +} + // Warn if we can't open a file and return a fd. int FAST_FUNC open3_or_warn(const char *pathname, int flags, int mode) { -- cgit v1.2.3