summary refs log tree commit diff
path: root/pkgs/test/make-binary-wrapper/chdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/test/make-binary-wrapper/chdir.c')
-rw-r--r--pkgs/test/make-binary-wrapper/chdir.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/pkgs/test/make-binary-wrapper/chdir.c b/pkgs/test/make-binary-wrapper/chdir.c
new file mode 100644
index 00000000000..ff1f91a03ba
--- /dev/null
+++ b/pkgs/test/make-binary-wrapper/chdir.c
@@ -0,0 +1,14 @@
+// makeCWrapper /path/to/executable \
+    --chdir /usr/local/bin
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
+
+int main(int argc, char **argv) {
+    assert_success(chdir("/usr/local/bin"));
+    argv[0] = "/path/to/executable";
+    return execv("/path/to/executable", argv);
+}
\ No newline at end of file