Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!munnari!gwydir!gara!wtoomey From: wtoomey@gara.une.oz (Warren Toomey) Newsgroups: comp.os.minix Subject: Official Clam Patch #2 (Part 1 of 4) Message-ID: <779@gara.une.oz> Date: 1 Jun 89 10:34:02 GMT Organization: University of New England, Armidale, Australia Lines: 580 # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # CRCLIST builtin.cdif clex.cdif echo x - CRCLIST cat > "CRCLIST" << '//E*O*F CRCLIST//' 57497 4917 alias.c 29568 27856 builtin.c 50076 18172 clex.c 41126 18739 comlined.c 15958 3449 cx.c 34060 189 dotclamr 60211 278 dotlogin 58306 16755 exec.c 53894 977 file.c 02377 1132 global.c 19850 8673 hash.c 60345 7427 header.h 18466 4529 hist.c 34831 10067 job.c 42195 21184 main.c 58968 2660 makefile 53495 26347 meta.c 26813 9392 parse.c 07214 11738 var.c //E*O*F CRCLIST// echo x - builtin.cdif cat > "builtin.cdif" << '//E*O*F builtin.cdif//' *** ../Patch1/builtin.c Thu Jun 1 17:01:14 1989 --- builtin.c Thu Jun 1 16:53:15 1989 *************** *** 57,62 # endif #endif else write(2,"Can't get cwd properly\n",23); } static --- 57,63 ----- # endif #endif else write(2,"Can't get cwd properly\n",23); + free(argv[1]); /* just in case? */ } static *************** *** 66,71 bool appnd,bckgnd; { extern void setdown(); extern int fromfile,isanum(); if (argc>2 || (!isanum(argv[1]) && argc!=1)) --- 67,73 ----- bool appnd,bckgnd; { extern void setdown(); + extern bool loginsh; extern int fromfile,isanum(); void logout(); /* just down from here... */ *************** *** 67,72 { extern void setdown(); extern int fromfile,isanum(); if (argc>2 || (!isanum(argv[1]) && argc!=1)) { --- 69,75 ----- extern void setdown(); extern bool loginsh; extern int fromfile,isanum(); + void logout(); /* just down from here... */ if (loginsh==TRUE) logout(argc,argv,infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd); *************** *** 68,73 extern void setdown(); extern int fromfile,isanum(); if (argc>2 || (!isanum(argv[1]) && argc!=1)) { write(2,"Bad argument to exit.\n",22); --- 71,78 ----- extern int fromfile,isanum(); void logout(); /* just down from here... */ + if (loginsh==TRUE) + logout(argc,argv,infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd); if (argc>2 || (!isanum(argv[1]) && argc!=1)) { write(2,"Bad argument to exit.\n",22); *************** *** 645,650 { extern void joblist(); joblist(); } --- 650,656 ----- { extern void joblist(); + /* Have -i or -l flag which gives more info. (stuff in job struct) */ joblist(); } *************** *** 759,765 int pid,i; signal(SIGCHLD,SIG_IGN); /* so that checkjobs doesn't update */ - setexec(); /* set the signal-sending keys */ if (argc==1) { #ifdef DEBUG --- 765,770 ----- int pid,i; signal(SIGCHLD,SIG_IGN); /* so that checkjobs doesn't update */ if (argc==1) { #ifdef DEBUG *************** *** 768,774 if (currentjob) { pid=currentjob->pid; /* current job */ ! if (setpgrp(pid,getpgrp(0))==-1) /* set process group to the shell's */ { write(2,"Can't fg this pid\n",18); return; --- 773,779 ----- if (currentjob) { pid=currentjob->pid; /* current job */ ! if (pid!=getpgrp(pid)) { fprintf(stderr,"Can't bring pid:%d to the foreground. Impossible?\n",pid); fflush(stderr); *************** *** 770,775 pid=currentjob->pid; /* current job */ if (setpgrp(pid,getpgrp(0))==-1) /* set process group to the shell's */ { write(2,"Can't fg this pid\n",18); return; } --- 775,791 ----- pid=currentjob->pid; /* current job */ if (pid!=getpgrp(pid)) { + fprintf(stderr,"Can't bring pid:%d to the foreground. Impossible?\n",pid); + fflush(stderr); + return; + } + #ifdef DEBUG + fprintf(stderr,"setting terminal pg to %d\n",pid); + #endif + if (ioctl(0,TIOCSPGRP,&pid)) perror("fg spg"); + setdown(); + /*if (setpgrp(pid,getpgrp(0))==-1) /* set process group to the shell's + { write(2,"Can't fg this pid\n",18); return; } *** This is wrong. All are in their own process group now */ *************** *** 772,778 { write(2,"Can't fg this pid\n",18); return; ! } c=vget("cwd"); if (strcmp(currentjob->dir,c)) /* if directory has changed */ fprintf(stderr,"[%d] %d %s (wd now: %s)\n",currentjob->jobnumber,currentjob->pid,currentjob->name,currentjob->dir); --- 788,794 ----- { write(2,"Can't fg this pid\n",18); return; ! } *** This is wrong. All are in their own process group now */ c=vget("cwd"); if (strcmp(currentjob->dir,c)) /* if directory has changed */ fprintf(stderr,"[%d] %d %s (wd now: %s)\n",currentjob->jobnumber,currentjob->pid,currentjob->name,currentjob->dir); *************** *** 781,788 fflush(stderr); update(pid,0); /* clear status */ newcurr(); /* change current job to this one (with luck) */ ! kill(pid,SIGCONT); ! (void) waitfor(pid); /* do the waiting here. */ return; } else --- 797,807 ----- fflush(stderr); update(pid,0); /* clear status */ newcurr(); /* change current job to this one (with luck) */ ! #ifdef DEBUG ! fprintf(stderr,"sending CONT to %d grp\n",pid); ! #endif ! if (killpg(pid,SIGCONT)) perror("killpg"); ! else (void) waitfor(pid); /* do the waiting here. */ return; } else *************** *** 812,818 #ifdef DEBUG fprintf(stderr,"fg-ing %d\n",pid); #endif ! if (setpgrp(pid,getpgrp(0))==-1) /* set process group to the shell's */ { write(2,"Can't fg this pid\n",18); return; --- 831,837 ----- #ifdef DEBUG fprintf(stderr,"fg-ing %d\n",pid); #endif ! if (pid!=getpgrp(pid)) { fprintf(stderr,"Can't bring pid:%d to the foreground.\n",pid); fflush(stderr); *************** *** 814,819 #endif if (setpgrp(pid,getpgrp(0))==-1) /* set process group to the shell's */ { write(2,"Can't fg this pid\n",18); return; } --- 833,845 ----- #endif if (pid!=getpgrp(pid)) { + fprintf(stderr,"Can't bring pid:%d to the foreground.\n",pid); + fflush(stderr); + continue; + } + setexec(pid); /* + /*if (setpgrp(pid,getpgrp(0))==-1) /* set process group to the shell's + { write(2,"Can't fg this pid\n",18); return; } *** This is wrong. All things are in their own group now */ *************** *** 816,822 { write(2,"Can't fg this pid\n",18); return; ! } ptr=findjob(pid); c=vget("cwd"); if (strcmp(ptr->dir,c)) /* if directory has changed */ --- 842,848 ----- { write(2,"Can't fg this pid\n",18); return; ! } *** This is wrong. All things are in their own group now */ ptr=findjob(pid); c=vget("cwd"); if (strcmp(ptr->dir,c)) /* if directory has changed */ *************** *** 826,833 fflush(stderr); update(pid,0); /* clear status */ newcurr(); /* change current job to this one (with luck) */ ! kill(pid,SIGCONT); ! (void) waitfor(pid); /* do the waiting here. */ } } --- 852,862 ----- fflush(stderr); update(pid,0); /* clear status */ newcurr(); /* change current job to this one (with luck) */ ! #ifdef DEBUG ! fprintf(stderr,"sending CONT to %d pg\n",pid); ! #endif ! if (killpg(pid,SIGCONT)) perror("killpg"); ! else (void) waitfor(pid); /* do the waiting here. */ } } *************** *** 848,854 if (currentjob) { pid=currentjob->pid; /* current job */ ! if (setpgrp(pid,pid)==-1) { write(2,"Can't bg this pid\n",18); return; --- 877,883 ----- if (currentjob) { pid=currentjob->pid; /* current job */ ! /*if (setpgrp(pid,pid)==-1) { write(2,"Can't bg this pid\n",18); return; *************** *** 852,858 { write(2,"Can't bg this pid\n",18); return; ! } fprintf(stderr,"[%d] %d %s\n",currentjob->jobnumber,currentjob->pid,currentjob->name); fflush(stderr); update(pid,0); /* clear status */ --- 881,887 ----- { write(2,"Can't bg this pid\n",18); return; ! } *** Don't need this, already done now */ fprintf(stderr,"[%d] %d %s\n",currentjob->jobnumber,currentjob->pid,currentjob->name); fflush(stderr); update(pid,0); /* clear status */ *************** *** 857,863 fflush(stderr); update(pid,0); /* clear status */ newcurr(); /* change current job to this one (with luck) */ ! kill(pid,SIGCONT); } else { --- 886,895 ----- fflush(stderr); update(pid,0); /* clear status */ newcurr(); /* change current job to this one (with luck) */ ! #ifdef DEBUG ! fprintf(stderr,"killpg on pid %d\n",pid); ! #endif ! if (killpg(pid,SIGCONT)) perror("killpg"); } else { *************** *** 883,889 if (!isanum(c)) continue; pid=atoi(c); } ! if (setpgrp(pid,pid)==-1) { write(2,"Can't bg this pid\n",18); return; --- 915,921 ----- if (!isanum(c)) continue; pid=atoi(c); } ! /*if (setpgrp(pid,pid)==-1) { write(2,"Can't bg this pid\n",18); return; *************** *** 887,893 { write(2,"Can't bg this pid\n",18); return; ! } ptr=findjob(pid); fprintf(stderr,"[%d] %d %s\n",ptr->jobnumber,ptr->pid,ptr->name); fflush(stderr); --- 919,925 ----- { write(2,"Can't bg this pid\n",18); return; ! } *** Don't need this, now, already done */ ptr=findjob(pid); fprintf(stderr,"[%d] %d %s\n",ptr->jobnumber,ptr->pid,ptr->name); fflush(stderr); *************** *** 893,899 fflush(stderr); update(pid,0); /* clear status */ newcurr(); /* change current job to this one (with luck) */ ! kill(pid,SIGCONT); } } --- 925,931 ----- fflush(stderr); update(pid,0); /* clear status */ newcurr(); /* change current job to this one (with luck) */ ! if (killpg(pid,SIGCONT)) perror("killpg"); } } //E*O*F builtin.cdif// echo x - clex.cdif cat > "clex.cdif" << '//E*O*F clex.cdif//' *** ../Patch1/clex.c Thu Jun 1 17:01:44 1989 --- clex.c Thu Jun 1 16:53:46 1989 *************** *** 129,135 int i=0,max,looping=1,bltin; char c; - buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat))); yankprev(line,*pos,word); /* first get the thing we're trying to expand */ /* Look for a slash to see if its a relative path name or current directory. --- 129,134 ----- int i=0,max,looping=1,bltin; char c; yankprev(line,*pos,word); /* first get the thing we're trying to expand */ /* Look for a slash to see if its a relative path name or current directory. *************** *** 205,210 } max=strlen(&word[i+1]); start=0; while ((entry=readdir(dd))!=NULL) /* Check to see if the chars we typed match so far */ if (!strncmp(&word[i+1],entry->d_name,max)) --- 204,210 ----- } max=strlen(&word[i+1]); start=0; + buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat))); while ((entry=readdir(dd))!=NULL) /* Check to see if the chars we typed match so far */ if (!strncmp(&word[i+1],entry->d_name,max)) *************** *** 227,232 else ptr->c_isdir=FALSE; } closedir(dd); } } else /* no slash */ --- 227,233 ----- else ptr->c_isdir=FALSE; } closedir(dd); + free(buf); } } else /* no slash */ *************** *** 239,244 printf("\n%sCan't open %s\n",beep,PASSWD); prprompt(1); show(line,curs,TRUE); } for (i=0;word[i];i++) word[i]=word[i+1]; --- 240,246 ----- printf("\n%sCan't open %s\n",beep,PASSWD); prprompt(1); show(line,curs,TRUE); + return; } for (i=0;word[i];i++) word[i]=word[i+1]; *************** *** 318,323 } if (t!=WORD) continue; /* illegal path component ignored */ if ((dd=opendir(dir))==NULL) continue; /* same again */ while ((entry=readdir(dd))!=NULL) /* Check to see if the chars we typed match so far */ if (!strncmp(word,entry->d_name,max)) --- 320,326 ----- } if (t!=WORD) continue; /* illegal path component ignored */ if ((dd=opendir(dir))==NULL) continue; /* same again */ + buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat))); while ((entry=readdir(dd))!=NULL) /* Check to see if the chars we typed match so far */ if (!strncmp(word,entry->d_name,max)) *************** *** 340,345 else ptr->c_isdir=FALSE; } closedir(dd); } /* end while retsym*/ } /* end else ~ */ } /* end else findslash */ --- 343,349 ----- else ptr->c_isdir=FALSE; } closedir(dd); + free(buf); } /* end while retsym*/ } /* end else ~ */ } /* end else findslash */ *************** *** 416,422 int i,bltin,max,index=0,maxlength=0,temp,compare(); extern int beeplength; - buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat))); if ((pos==0) || (line[pos-1]==' ')) strcpy(word,""); /* nothing there to get */ else --- 420,425 ----- int i,bltin,max,index=0,maxlength=0,temp,compare(); extern int beeplength; if ((pos==0) || (line[pos-1]==' ')) strcpy(word,""); /* nothing there to get */ else *************** *** 488,493 show(line,curs,TRUE); return; } while ((entry=readdir(dd))!=NULL) { if (entry->d_name[0]=='.' && (entry->d_name[1]=='.' || entry->d_name[1]==EOS)) --- 491,497 ----- show(line,curs,TRUE); return; } + buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat))); while ((entry=readdir(dd))!=NULL) { if (entry->d_name[0]=='.' && (entry->d_name[1]=='.' || entry->d_name[1]==EOS)) *************** *** 512,517 } } closedir(dd); } } else /* no slash */ --- 516,522 ----- } } closedir(dd); + free(buf); } } else /* no slash */ //E*O*F clex.cdif// exit 0