Hi,
I'm writing a basic shell, and having some issues. I've searched the manpages, google, and this forum, but with no luck, so here's my problem.
execve is working fine for commands that have no arguments, but when it requires arguments, I get a bad address error (returned by perror).
This is how I'm initializing my parameter array:
char (*params)[MAX_CHAR];
params = malloc(MAX_PARAM * sizeof *params);
I have MAX_CHAR set to 64, MAX_PARAM set to 16.
Now, my program sets a simple char array called command to "/bin/mkdir", and copies the characters to params[0]. I set params[1][0] to 'a' and params[1][1] to 'a'. I've confirmed that this is exactly what's happened. I've printed each individual character in command, identifying null characters. I did the same thing with params[0] and params[1]. commands[10] == NULL, params[0][10] == NULL, params[1][2] == NULL, and params[2][0] == NULL. As far as I can tell I've met all the conditions for this to work, but it still will not... still getting a "bad address" error.
Hopefully I've explained my problem sufficiently. Any ideas?
Thanks.