BUona domenica a tutti,sono un nuovo iscritto e mi trovo subito a dover fare una domanda
.....e.....codice:#include "smallsh.h" static char inpbuf[MAXBUF], tokbuf[2*MAXBUF], *ptr, *tok; static char special[]= {' ', '\t', '&', ';', '\n', '\0'}; int userin(char *p) { int c, count; ptr = inpbuf; tok = tokbuf; printf("%s ",p); count=0; while(1) { if ((c = getchar()) == EOF) return(EOF); if (count < MAXBUF) inpbuf[count++] = c; if (c == '\n' && count < MAXBUF) { inpbuf[count] = '\0'; return(count); } if (c == '\n') { printf("riga in input troppo lunga\n"); count = 0; printf("%s ",p); } } } int gettok(char **outptr) { int type; *outptr = tok; while (*ptr == ' ' || *ptr == '\t') ptr++; *tok++ = *ptr; switch(*ptr++){ case '\n': type = EOL; break; case '&': type = AMPERSAND; break; case ';': type = SEMICOLON; break; default: type = ARG; while(inarg(*ptr)) *tok++ = *ptr++; } *tok++ = '\0'; return(type); } int inarg(char c) { char *wrk; for (wrk = special; *wrk != '\0'; wrk++) if (c == *wrk) return(0); return(1); }
in questo codice devo evitare che un segnale termini tutto,deve terminare solo il figlio e rendere attiva la possibilità di usare & per il backgroundcodice:#include "smallsh.h" #include <sys/types.h> #include <stdlib.h> char *prompt = "Comando"; int procline(void) { char *arg[MAXARG+1]; int toktype; int narg; int type; narg=0; while (1) { switch (toktype = gettok(&arg[narg])) { case ARG: if (narg < MAXARG) narg++; break; case EOL: case SEMICOLON: case AMPERSAND: type = (toktype == AMPERSAND) ? BACKGROUND : FOREGROUND; if (narg != 0) { arg[narg] = NULL; runcommand(arg,type); } if (toktype == EOL) return; narg = 0; break; } } }
Mi potete dare consigli?Come faccio a disattivare nel primo caso l' "uscita"?

Rispondi quotando