X-Git-Url: https://git.saurik.com/apple/network_cmds.git/blobdiff_plain/342c141ecf761e55ea0f23a89d835a8544df5f2e..d9520f62e711f9e90f2db3a98bd16ef30eb26a13:/cfilutil/cfilutil.c diff --git a/cfilutil/cfilutil.c b/cfilutil/cfilutil.c index 546604c..4aaa719 100644 --- a/cfilutil/cfilutil.c +++ b/cfilutil/cfilutil.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014 Apple Inc. All rights reserved. + * Copyright (c) 2013-2016 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -476,14 +476,19 @@ doit() kv.filter = EVFILT_READ; kv.flags = EV_ADD; if (kevent(kq, &kv, 1, NULL, 0, NULL) == -1) - err(1, "kevent(sf)"); - - bzero(&kv, sizeof(struct kevent)); - kv.ident = fdin; - kv.filter = EVFILT_READ; - kv.flags = EV_ADD; - if (kevent(kq, &kv, 1, NULL, 0, NULL) == -1) - err(1, "kevent(sf)"); + err(1, "kevent(sf %d)", sf); + + /* + * We can only read from an interactive terminal + */ + if (isatty(fdin)) { + bzero(&kv, sizeof(struct kevent)); + kv.ident = fdin; + kv.filter = EVFILT_READ; + kv.flags = EV_ADD; + if (kevent(kq, &kv, 1, NULL, 0, NULL) == -1) + err(1, "kevent(fdin %d)", fdin); + } buffer = malloc(MAX_BUFFER); if (buffer == NULL)