i´m creating a little shell, and each time i execute a command i want it toCode:while(1) { char cmd[20]; printf("Shell: "); scanf("%s",&cmd); res = fork(); if(res==0) { if((strcmp("ls",cmd))==0) { execl("/bin/ls","ls",NULL); insert_list(list, "ls"); } if((strcmp("ps",cmd))==0) { execl("/bin/ps","ps",NULL); insert_list(list, "ps"); } if((strcmp("historic",cmd))==0) { Print_list(list); } } else { wait(&status); } } }
be saved in a linked list, so when i execute the command historic, it prints the commands i had executed before. But when i execute command historic the list don´t print nothing. I think it is because execl, because if i take the instruction execl("/bin/ls","ls",NULL); it prints the list with the elements correct, in this case ls.
Sorry about the English.