summaryrefslogtreecommitdiffstats
path: root/testModule/wrap.c
blob: 0f1182353e24764b2a470ab03a8310ef0bc0e791 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;
	}
}