Return to BSD News archive
Path: sserve!manuel!munnari.oz.au!mips!mips!swrinde!cs.utexas.edu!uunet!uunet.ca!cognos!dealwisb From: dealwisb@cognos.com (Brian de Alwis) Newsgroups: comp.unix.bsd Subject: Core-names - patch, and a howto for more Message-ID: <1992Jun22.025905.8717@cognos.com> Date: 22 Jun 92 02:59:05 GMT Organization: Cognos Incorporated, Ottawa CANADA Lines: 74 Here's a minor patch for sys/kern/kern_sig.c for generation of core files. As the file sits, the system will generate a core file using the full name of the executable. So, if you dump core while running /bin/zsh, the kernel tries to create a core "core./bin/sh", which is invalid, unless you have a director core./. This patch will cause the basename to be used. Also, more(1) (yes, I prefer it to less!) has another small bug when using a repeat search (ie. /something, and then "n"), as the search() routine is passed a NULL buffer, but search() doesn't keep the last regexp (a local var called "s"). The solution is to remove the free(s) from the lower-part of search(), make s a static, and place the following near the beginning: if(buf) { /* We want to search for something new */ if(s) /* We have the regexp from the last search ... */ free(s); /* ... so get rid of it */ s = regexp(buf) } Sorry I don't have a diff, but I forgot to save a copy of the old code. *** /sys/kern/kern_sig.c.old Sun Jun 21 00:10:03 1992 --- /sys/kern/kern_sig.c Sun Jun 21 17:15:42 1992 *************** *** 1009,1014 **** --- 1009,1023 ---- /* NOTREACHED */ } + char *rindex(s,c) + char *s,c; + { char *r=(char *)NULL; + while(*s) + if(*s++ == c) + r = s-1; + return(r); + } + /* * Create a core dump. * The file name is "core.progname". *************** *** 1025,1030 **** --- 1034,1043 ---- int error, error1; struct nameidata nd; char name[MAXCOMLEN+6]; /* core.progname */ + char *temp = rindex(p->p_comm,'/'); + + if(!temp++) + temp = p->p_comm; if (pcred->p_svuid != pcred->p_ruid || pcred->p_svgid != pcred->p_rgid) *************** *** 1032,1038 **** if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >= p->p_rlimit[RLIMIT_CORE].rlim_cur) return (EFAULT); ! sprintf(name, "core.%s", p->p_comm); nd.ni_dirp = name; nd.ni_segflg = UIO_SYSSPACE; if (error = vn_open(&nd, p, O_CREAT|FWRITE, 0644)) --- 1045,1051 ---- if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >= p->p_rlimit[RLIMIT_CORE].rlim_cur) return (EFAULT); ! sprintf(name, "core.%s", temp); nd.ni_dirp = name; nd.ni_segflg = UIO_SYSSPACE; if (error = vn_open(&nd, p, O_CREAT|FWRITE, 0644)) -- +++BdA Brian de Alwis. Brain on loan to Cognos Inc, Ottawa, Ontario. dealwisb@cognos.com, or bsdealwis@napier.waterloo.edu "Nine out of ten men who tried camels said they preferred women"