diff options
| author | Jonathan Bauer | 2015-04-13 16:55:04 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2015-04-13 16:55:04 +0200 |
| commit | 44a3841d6bf3e2743a86f7257689f45b2f1e343b (patch) | |
| tree | c7c6a9155335f1db7c1c53501bdfc9e9d75d812b /testModule/wrap.c | |
| parent | Nur noch pivot_switch fehlt! (diff) | |
| download | systemd-init-44a3841d6bf3e2743a86f7257689f45b2f1e343b.tar.gz systemd-init-44a3841d6bf3e2743a86f7257689f45b2f1e343b.tar.xz systemd-init-44a3841d6bf3e2743a86f7257689f45b2f1e343b.zip | |
basic wrapper
Diffstat (limited to 'testModule/wrap.c')
| -rw-r--r-- | testModule/wrap.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/testModule/wrap.c b/testModule/wrap.c new file mode 100644 index 00000000..0f118235 --- /dev/null +++ b/testModule/wrap.c @@ -0,0 +1,41 @@ +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +void arg_print(int argc, char *argv[]) { + int i = 0; + int j = 0; + for (i = 0; i < argc; i ++) { + j = 0; + while(argv[i][j] != '\0') + printf("%c", argv[i][j++]); + + printf(" "); + } + printf("\n"); +} + + +int main(int argc, char *argv[]) { + + arg_print(argc, argv); + + int count; + char **copy = malloc(sizeof(char *) * (argc-1)); + for ( count = 0; count < argc - 1; count++ ) { + copy[count] = strdup(argv[count + 1]); + } + + arg_print(argc - 1, copy); + + copy[0][0] = '@'; + argv[0][0] = '@'; + + arg_print(argc - 1, copy); + + if (-1 == execvp(argv[1], copy)) { + perror("child process execve failed [%m]"); + return -1; + } +} |
