about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2021-02-28 22:44:47 +0100
committerLeah Neukirchen <leah@vuxu.org>2021-02-28 22:44:47 +0100
commit6c81764641c7fe4c6ac190a12b9308f4de54cb4e (patch)
treee3c80925d614188cfb3a75bf821fb84dbdd25ac8
parent8165cee0a12e3e88701dce293e4a930b6f166acd (diff)
downloadnq-6c81764641c7fe4c6ac190a12b9308f4de54cb4e.tar.gz
nq-6c81764641c7fe4c6ac190a12b9308f4de54cb4e.tar.xz
nq-6c81764641c7fe4c6ac190a12b9308f4de54cb4e.zip
fq: fix fd leak
Thanks to @duncaen for reporting.
-rw-r--r--fq.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fq.c b/fq.c
index 1a702d6..ebfe6f8 100644
--- a/fq.c
+++ b/fq.c
@@ -162,8 +162,10 @@ main(int argc, char *argv[])
 
 		/* skip not running jobs, unless -a was passed, or we did not
 		 * output anything yet and are at the last argument.  */
-		if (!aflag && !islocked(fd) && (didsth || i != argc - 1))
+		if (!aflag && !islocked(fd) && (didsth || i != argc - 1)) {
+			close(fd);
 			continue;
+		}
 
 		write(1, "==> ", 4);
 		write(1, argv[i], strlen(argv[i]));