commit 2b921f50ae0cb12589cdbb01589b662bf38999f1
Author: Louis Burda <quent.burda@gmail.com>
Date: Tue, 7 Mar 2023 13:09:11 +0100
Initial version
Diffstat:
3 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1 @@
+waitdbg
diff --git a/Makefile b/Makefile
@@ -0,0 +1,17 @@
+PREFIX ?= /usr/local
+BINDIR ?= /bin
+
+all: waitdbg
+
+clean:
+ rm -f waitdbg
+
+waitdbg: waitdbg.c
+
+install:
+ install -m755 waitdbg -t "$(DESTDIR)$(PREFIX)$(BINDIR)"
+
+uninstall:
+ rm "$(DESTDIR)$(PREFIX)$(BINDIR)/waitdbg"
+
+.PHONY: all clean install uninstall
diff --git a/waitdbg.c b/waitdbg.c
@@ -0,0 +1,23 @@
+#include <unistd.h>
+#include <signal.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, const char **argv)
+{
+ int ret;
+
+ if (argc < 2) {
+ printf("Usage: waitdbg CMD [ARG]..\n");
+ return 0;
+ }
+
+ fprintf(stderr, "waitdbg: pid %u (%s)\n", getpid(), argv[1]);
+
+ raise(SIGSTOP);
+
+ ret = execv(argv[1], (void *) &argv[1]);
+ if (!ret) err(1, "execv %s", argv[1]);
+}