commit 5e086cdcf8e030c7db7712e90b632cc55a4f25e2
parent 2b921f50ae0cb12589cdbb01589b662bf38999f1
Author: Louis Burda <quent.burda@gmail.com>
Date: Thu, 9 Nov 2023 00:17:45 +0100
Remove err.h dependency and use execvp()
Diffstat:
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/waitdbg.c b/waitdbg.c
@@ -1,16 +1,15 @@
#include <unistd.h>
#include <signal.h>
-#include <err.h>
+#include <errno.h>
+#include <string.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");
+ fprintf(stderr, "Usage: waitdbg CMD [ARG]..\n");
return 0;
}
@@ -18,6 +17,8 @@ main(int argc, const char **argv)
raise(SIGSTOP);
- ret = execv(argv[1], (void *) &argv[1]);
- if (!ret) err(1, "execv %s", argv[1]);
+ execvp(argv[1], (void *) &argv[1]);
+
+ fprintf(stderr, "waitdbg: execv %s: %s",
+ argv[1], strerror(errno));
}