perche se eseguo questo codice e passo come comando date funziona e se invece passo ls non va?
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
char * read_command() {
char *command;
scanf("%as",&command);
return command;
}
int main () {
char *command;
int pid,*status;
command=read_command();
if ((pid=fork()) !=0) {
waitpid(-1,status,0);
printf("Il processo figlio %d &#65533; uscito con lo stato %d\n",pid,*status);
}
else {
execvp(command,NULL);
}
exit(0);
}
ciao
Arpda
__________________
Membro di HWU Scout Group || Quello che ieri era fantascienza oggi è realtà, quello che oggi è realtà domani sarà solo un ricordo ...
Powered by Gentoo 1.4 on kernel 2.6.12.-gentoo-r4
|