aboutsummaryrefslogtreecommitdiffstats
path: root/guts/execlp.c
diff options
context:
space:
mode:
Diffstat (limited to 'guts/execlp.c')
-rw-r--r--guts/execlp.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/guts/execlp.c b/guts/execlp.c
new file mode 100644
index 0000000..8fd2cdf
--- /dev/null
+++ b/guts/execlp.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010 Wind River Systems; see
+ * guts/COPYRIGHT for information.
+ *
+ * static int
+ * wrap_execlp(const char *file, const char *arg, va_list ap) {
+ * int rc = -1;
+ */
+
+ size_t i = 0;
+ size_t alloc_size = 256;
+ const char **argv = malloc(sizeof (const char *) * alloc_size);
+
+ argv[i++] = arg;
+
+ while (argv[i-1]) {
+ argv[i++] = va_arg (ap, const char *);
+ if ( i > alloc_size - 1 ) {
+ alloc_size = alloc_size + 256;
+ argv = realloc(argv, sizeof (const char *) * alloc_size);
+ }
+ }
+
+ rc = wrap_execvp (file, (char *const *) argv);
+
+ free (argv);
+
+/* return rc;
+ * }
+ */