From 73e1f036259fca7c4cf0f38dc95b08417dd19ed0 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Sat, 9 Dec 2023 08:05:52 -0500 Subject: [PATCH] termux/android: stdin: remove call to fcntl() Remove an unnecessary call to put stdin into non-blocking mode. On termux/android, xmppipe is aborted when the fd capability set is changed: ``` FORTIFY: fcntl(F_SETFD) passed non-FD_CLOEXEC flag: 0x800 libc: FORTIFY: fcntl(F_SETFD) passed non-FD_CLOEXEC flag: 0x800 libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 32292 (xmppipe), pid 32292 () libc: failed to spawn debuggerd dispatch thread: Try again ``` --- src/xmppipe.h | 1 - src/xmppipe_event.c | 3 --- src/xmppipe_util.c | 13 ------------- 3 files changed, 17 deletions(-) diff --git a/src/xmppipe.h b/src/xmppipe.h index bf9974c..d287be5 100644 --- a/src/xmppipe.h +++ b/src/xmppipe.h @@ -136,7 +136,6 @@ char *xmppipe_fmt_encode(const char *); char *xmppipe_nfmt_encode(const char *, size_t); char *xmppipe_fmt_decode(const char *); char *xmppipe_nfmt_decode(const char *, size_t); -int xmppipe_set_nonblock(int fd); char *xmppipe_resource(void); char *xmppipe_servername(const char *); diff --git a/src/xmppipe_event.c b/src/xmppipe_event.c index 6ea39db..e5c3154 100644 --- a/src/xmppipe_event.c +++ b/src/xmppipe_event.c @@ -25,9 +25,6 @@ void event_loop(xmppipe_state_t *state) { int eof = 0; char *buf; - if (xmppipe_set_nonblock(fd) < 0) - return; - buf = xmppipe_calloc(state->bufsz, 1); for (;;) { diff --git a/src/xmppipe_util.c b/src/xmppipe_util.c index 5bad731..6c47ef4 100644 --- a/src/xmppipe_util.c +++ b/src/xmppipe_util.c @@ -38,19 +38,6 @@ const char *const xmppipe_states[] = {"XMPPIPE_S_DISCONNECTED", static char *xmppipe_join(const char *prefix, const char *delimiter, const char *suffix); -int xmppipe_set_nonblock(int fd) { - int flags; - - flags = fcntl(fd, F_GETFD); - if (flags < 0) - return -1; - - if (fcntl(fd, F_SETFD, flags | O_NONBLOCK) < 0) - return -1; - - return 0; -} - char *xmppipe_getenv(const char *s) { char *p = getenv(s);