Warning: Undefined array key "view" in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 47
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 48
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 49
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 50
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php:2) in /var/www/html/wp-content/uploads/classes/so/1920/lab-examples/index.php on line 51
/**
* un abbozzo di funzionamento di una mini-shell (niente parametri)
*/
#include
#include
#include
#include
#include
#define LEN_BUFFER 1024
int main(int argc, char *argv[]) {
char comando[LEN_BUFFER];
int pid, len;
while (1) {
printf("Digitare un comando da eseguire ('quit' per uscire): ");
fgets(comando, LEN_BUFFER, stdin);
len = strlen(comando);
if (comando[len - 1] == '\n')
comando[len - 1] = '\0';
if (strcmp(comando, "quit") == 0)
break;
pid = fork();
if (pid == -1) {
perror("fork");
exit(1);
}
if (pid == 0) {
execlp(comando, comando, NULL);
fprintf(stderr, "Errore nell'esecuzione di '%s'\n", comando);
exit(2);
} else {
wait(NULL);
}
}
exit(0);
}