浏览代码

fix: close descriptor if failed to attach stream

David Marec 1 周之前
父节点
当前提交
520ae25c11
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      kqueue/kq_timer.c

+ 2 - 1
kqueue/kq_timer.c

@@ -103,7 +103,8 @@ int main(int argc, char *argv[])
 
 	fd = fdopen(fdx, "w");
 	if (fd == NULL) {
-		warn("fopen() failure");
+		warn("fdopen() failure");
+		close(fdx);
 		return EXIT_FAILURE;
 	}