aboutsummaryrefslogtreecommitdiff
path: root/src/run_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/run_cmd.c')
-rw-r--r--src/run_cmd.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/run_cmd.c b/src/run_cmd.c
new file mode 100644
index 0000000..aa15964
--- /dev/null
+++ b/src/run_cmd.c
@@ -0,0 +1,18 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main(int argc, char* argv[]) {
+ if (argc < 3) {
+ printf("Usage: %s <ld_preload> <cmd> [cmd args]\n");
+ printf("\tset LD_PRELOAD to ld_preload and call execvp <cmd> [cmd args]\n");
+ return 1;
+ }
+
+ // Overwrite LD_PRELOAD.
+ setenv("LD_PRELOAD", argv[1], 1);
+
+ // Run cmd.
+ execvp(argv[2], &argv[2]);
+}