void DMemModelThread::DoExit1() { // Regularize the thread state before main exit processing. // We must remove any existing alias before we do any operation // which requires aliasing (e.g. logon completion). __KTRACE_OPT(KTHREAD,Kern::Printf("DMemModelThread %O DoExit1",this)); RemoveAlias(); }
//Run commands that are built-in shell functions static void RunBuiltInCmd(commandT* cmd) { //Send SIGCONT to a backgrounded job, but do not give it the foreground if (strncmp(cmd->argv[0], "bg", 2) == 0) { //If there are two arguments in the command... if (cmd->argc == 2) //Bring the process with the given jobNumber continueBgJob(strtol(cmd->argv[1],NULL,10)); //If there is one argument in the command... else if (cmd->argc == 1) //Bring the most recent background process to the foreground continueBgJob(-1); else { fprintf(stderr, "Too many arguments were given with bg.\n"); } } //Return a backgrounded job to the foreground else if (strncmp(cmd->argv[0], "fg", 2) == 0) { //If there are two arguments in the command... if (cmd->argc == 2) //Bring the process with the given jobNumber bringToForeground(strtol(cmd->argv[1],NULL,10)); //If there is one argument in the command... else if (cmd->argc == 1) //Bring the most recent background process to the foreground bringToForeground(-1); else { fprintf(stderr, "Too many arguments were given with fg.\n"); } } //makenew alias else if (strncmp(cmd->argv[0], "alias", 5) == 0) { //If there are two arguments in the command... if (cmd->argc == 2) //make new binding AddAlias(cmd); //show all bindings else if (cmd->argc == 1) PrintAliases(); } else if (strncmp(cmd->argv[0], "unalias", 7) == 0) { RemoveAlias(cmd->argv[1]); } else if (strncmp(cmd->argv[0], "cd", 2) == 0) { int err; //If a directory is given, go to that directory if (cmd->argc == 2) err = chdir(cmd->argv[1]); //If a directory isn't given, go to the user's home directory else err = chdir(getenv("HOME")); //If there was a problem changing directories, print an error if (err == -1) fprintf(stderr, "%s\n", "Invalid directory\n"); } //Print the list of background jobs (bgJobsHead) else if (strncmp(cmd->argv[0], "jobs", 4) == 0){ PrintBgJobList(); } else { fprintf(stderr, "%s is an unrecognized internal command\n", cmd->argv[0]); fflush(stdout); } }
void ProcessTerm(Term t) { Term res; Atom procc=0; char regbuf[80]; if(is_compound(t)&&CompoundName(t)==OPR_LOCAL) { List l1,la=ConsumeCompoundArg(t,1); if(l_pro==0) { ErrorInfo(0); puts("local: must be within template."); return; } la=CommaToList(la); for(l1=la;l1;l1=ListTail(l1)) l_ali=AppendLast(l_ali, InterfSetAlias(MakeCompound1(OPR_ALIAS,ListFirst(l1)),0)); RemoveList(la); return; } /* if(is_compound(t) && GetAtomProperty(CompoundName(t),OPR_ALIAS)) {*/ if(!is_compound(t) || (CompoundName(t)!=OPR_ALIAS && CompoundName(t)!=OPR_IN && CompoundName(t)!=OPR_WHERE) ) { t=ProcessAlias(t); proc_hash(t); } /*WriteTerm(t);puts("");*/ /*}*/ if(is_list(t)) { List l, alisav; l_pro++; alisav=l_ali; l_ali=0; for(l=t;l;l=ListTail(l)) ProcessTerm(ListFirst(l)); if(l_ali) RemoveAlias(l_ali); RemoveList(t); l_pro--; l_ali=alisav; return; } if(is_atom(t)) procc=t; if(is_compound(t)) { procc=CompoundName(t); } if(procc==0) { if(!IsTermInput()) printf("File \"%s\", line %d: ",CurrentInputFile(), CurrentInputLine()); printf("Not a valid operator \'"); WriteTerm(t); printf("\'.\n"); FreeAtomic(t); return; } if(!IsTermInput()) sprintf(regbuf, "ProcTerm: File %s, line %d: %s statement.", CurrentInputFile(), CurrentInputLine(), AtomValue(procc)); else sprintf(regbuf, "(tty): %s statement.",AtomValue(procc)); RegisterLine(regbuf); if(!is_function(t,NULL)) { if(!IsTermInput()) printf("File \"%s\", line %d: ",CurrentInputFile(), CurrentInputLine()); printf("Unknown operator \'%s\' in expression\n\t",AtomValue(procc)); WriteTerm(t); puts(""); FreeAtomic(t); UnregisterLine(); return; } if(is_compound(t) && ((VerbMode && CompoundName(t)==OPR_LTERM) || VerbMode==3)) { char sment[1024]; sWriteTerm(sment,t); sment[55]='.'; sment[56]='.'; sment[57]='.'; sment[58]=0; printf("%s:%3d: %s\n",CurrentInputFile(),CurrentInputLine(),sment); } res=CallFunction(t,0); if(res!=0 && (IsTermInput())) { if(is_compound(res) && CompoundArity(t)==2 && CompoundName(res)==A_ALG1) res=Alg1ToExpr(res); if(is_list(res)) DumpList(res); else { WriteTerm(res); puts(""); } FreeAtomic(res); } UnregisterLine(); }