tquery

Interactive command query tool
git clone https://git.sinitax.com/sinitax/tquery
Log | Files | Refs | LICENSE | sfeed.txt

commit 6cd4e062211fd9566862fbe69a73d7a59accd0e5
parent 1113d1a57e92f96b6ade240cf6e973ba25c3b4f4
Author: Louis Burda <contact@sinitax.com>
Date:   Wed, 18 Jun 2025 22:50:19 +0200

Fix fd leak and add DEBUG makefile flag

Diffstat:
MMakefile | 13++++++++++---
Mtquery.c | 1+
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,11 +1,18 @@ PREFIX ?= /usr/local BINDIR ?= /bin -CFLAGS = -std=c99 -D_XOPEN_SOURCE=700 -Og -g -Wunused-function \ - -Wunused-variable -Wconversion -Wsign-compare -Wuninitialized \ - $(CFLAGS_EXTRA) +CFLAGS = -std=c99 -D_XOPEN_SOURCE=700 -Wunused-function -Wunused-variable \ + -Wconversion -Wsign-compare -Wuninitialized LDFLAGS = -lcurses +ifeq ($(DEBUG),1) + CFLAGS += -fsanitize=address -Og -g +else + CFLAGS += -O3 +endif + +CFLAGS += $(CFLAGS_EXTRA) + all: tquery clean: diff --git a/tquery.c b/tquery.c @@ -156,6 +156,7 @@ invoke(const char **argv, pid_t *pid, int *fd, bool in, bool out, bool err) *pid = fork(); if (*pid < 0) die("fork:"); if (!*pid) { + if (child_fd) close(child_fd); if (!in || !out || !err) { int zfd = open("/dev/null", O_RDWR); if (zfd < 0) die("open /dev/null");