diff --git a/apps/fsearch/fsearch.cpp b/apps/fsearch/fsearch.cpp index 09f479d1baf43222ad10a933e4ed99dcd9db069b..118253b0b902288100f6b52efefd9c9b9a8add8a 100644 --- a/apps/fsearch/fsearch.cpp +++ b/apps/fsearch/fsearch.cpp @@ -38,7 +38,7 @@ void search(const std::string& path) { while (bytes_read > 0) { if (memmem(&buf[0], bytes_read, needle, needle_len)) { printf("%s\n", path.c_str()); - return; + goto out; } bytes_searched += bytes_read; @@ -48,6 +48,9 @@ void search(const std::string& path) { if (bytes_read < 0) { DIE_MSG_ERRNO("read failed"); } + +out: + emper::io::closeAndForget(fd); } void walk_dir() {