Closed hlao002 closed 9 years ago
are you making sure the last Argv is terminated by a null character?? that might be your problem
that's you have to check. please refer #276
It seems like you incorrectly assigned the null terminating. It should be the last array not the end of each array as you wrote the code Argv[cmd.size()] = NULL;
but I think it should be Argv[j] = NULL;
Right? please change it. I think it will be fine. Let me know
It solved.
While running the program at home, the program works perfectly fine. But when testing the program in hammer, all commands randomly fail giving the error "execvp: Bad address"
Note* the Argv[i]s == are whats being pass into execvp.
Output 1:
hlao002@hammer.cs.ucr.edu$ echo cat ; ls ; pwd Argv[0] ==echo Argv[1] ==cat cat Argv[0] ==ls a.out bin LICENSE Makefile README.md src Argv[0] ==pwd /home/csmajs/hlao002/CS100/rshell
Output 2:
hlao002@hammer.cs.ucr.edu$ echo cat ; ls ; pwd Argv[0] ==echo Argv[1] ==cat cat Argv[0] ==ls a.out bin LICENSE Makefile README.md src Argv[0] ==pwd execvp: Bad address hlao002@hammer.cs.ucr.edu$
Output 3:
hlao002@hammer.cs.ucr.edu$ echo cat ; ls ; pwd Argv[0] ==echo Argv[1] ==cat cat Argv[0] ==ls execvp: Bad address Argv[0] ==pwd execvp: Bad address
Any idea as to why this is happening?