* Copyright (C) 2006 Rob Landley
* Copyright (C) 2006 Denys Vlasenko
*
- * Licensed under GPL version 2, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this source tree.
*/
/* We need to have separate xfuncs.c and xfuncs_printf.c because
#include "libbb.h"
/* Turn on nonblocking I/O on a fd */
-int FAST_FUNC ndelay_on(int fd)
+void FAST_FUNC ndelay_on(int fd)
{
- return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
+ int flags = fcntl(fd, F_GETFL);
+ if (flags & O_NONBLOCK)
+ return;
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK);
}
-int FAST_FUNC ndelay_off(int fd)
+void FAST_FUNC ndelay_off(int fd)
{
- return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
+ int flags = fcntl(fd, F_GETFL);
+ if (!(flags & O_NONBLOCK))
+ return;
+ fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
}
-int FAST_FUNC close_on_exec_on(int fd)
+void FAST_FUNC close_on_exec_on(int fd)
{
- return fcntl(fd, F_SETFD, FD_CLOEXEC);
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
}
char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src)
char *s = getenv(env_name);
if (s) {
value = atoi(s);
- /* If LINES/COLUMNS are set, pretent that there is
+ /* If LINES/COLUMNS are set, pretend that there is
* no error getting w/h, this prevents some ugly
* cursor tricks by our callers */
*err = 0;