int printf(char*, ...); int scanf(char*, ...); int strcmp(char*, char*); int fork(); int waitpid(int, int*, int); void exit(int); int execve(char*, char**, char**); #define NULL (void*)0 int main(){ char command[4096]; // Sia argv che envp DEVONO terminare con un elemento NULL char* argv[] = {"", NULL}; char* envp[] = {NULL}; while (1){ int pid, status; printf("MYSHELL$ "); scanf("%s", command); if (strcmp(command, "exit") == 0) break; pid = fork(); if (pid != 0) { waitpid(pid, &status, 0); } else { argv[0] = command; execve(argv[0], argv, envp); printf("Da qui in poi esegue solo se l'execve e` fallita\n"); exit(0); } } return 0; }
Last modified
6 years ago
Last modified on Mar 27, 2019, 12:26:20 PM
Note:
See TracWiki
for help on using the wiki.