You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							195 lines
						
					
					
						
							4.8 KiB
						
					
					
				
			
		
		
	
	
							195 lines
						
					
					
						
							4.8 KiB
						
					
					
				# --- SDE-COPYRIGHT-NOTE-BEGIN --- | 
						|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. | 
						|
# | 
						|
# Filename: package/.../pdksh/pdksh-5.2.14-1.patch | 
						|
# Copyright (C) 2004 - 2006 The T2 SDE Project | 
						|
# Copyright (C) 1998 - 2003 Clifford Wolf | 
						|
# | 
						|
# More information can be found in the files COPYING and README. | 
						|
# | 
						|
# This patch file is dual-licensed. It is available under the license the | 
						|
# patched project is licensed under, as long as it is an OpenSource license | 
						|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms | 
						|
# of the GNU General Public License as published by the Free Software | 
						|
# Foundation; either version 2 of the License, or (at your option) any later | 
						|
# version. | 
						|
# --- SDE-COPYRIGHT-NOTE-END --- | 
						|
 | 
						|
 | 
						|
[ ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14-patches.1 ] | 
						|
 | 
						|
Here are patches for 3 significant bugs in pdksh-5.2.14: | 
						|
    - set -x dumps core (shf.c); | 
						|
    - output of "jobs" command is filled with ^A characters (jobs.c); | 
						|
    - "typeset -r foo=bar" fails saying foo is readonly (var.c). | 
						|
 | 
						|
--- ./shf.c | 
						|
+++ ./shf.c | 
						|
@@ -355,7 +355,6 @@ | 
						|
 		shf->rp = nbuf + (shf->rp - shf->buf); | 
						|
 		shf->wp = nbuf + (shf->wp - shf->buf); | 
						|
 		shf->rbsize += shf->wbsize; | 
						|
-		shf->wbsize += shf->wbsize; | 
						|
 		shf->wnleft += shf->wbsize; | 
						|
 		shf->wbsize *= 2; | 
						|
 		shf->buf = nbuf; | 
						|
 | 
						|
 | 
						|
--- ./var.c | 
						|
+++ ./var.c | 
						|
@@ -353,7 +353,9 @@ | 
						|
 	const char *s; | 
						|
 	int error_ok; | 
						|
 { | 
						|
-	if (vq->flag & RDONLY) { | 
						|
+	int no_ro_check = error_ok & 0x4; | 
						|
+	error_ok &= ~0x4; | 
						|
+	if ((vq->flag & RDONLY) && !no_ro_check) { | 
						|
 		warningf(TRUE, "%s: is read only", vq->name); | 
						|
 		if (!error_ok) | 
						|
 			errorf(null); | 
						|
@@ -715,13 +717,13 @@ | 
						|
 	if (val != NULL) { | 
						|
 		if (vp->flag&INTEGER) { | 
						|
 			/* do not zero base before assignment */ | 
						|
-			setstr(vp, val, KSH_UNWIND_ERROR); | 
						|
+			setstr(vp, val, KSH_UNWIND_ERROR | 0x4); | 
						|
 			/* Done after assignment to override default */ | 
						|
 			if (base > 0) | 
						|
 				vp->type = base; | 
						|
 		} else | 
						|
 			/* setstr can't fail (readonly check already done) */ | 
						|
-			setstr(vp, val, KSH_RETURN_ERROR); | 
						|
+			setstr(vp, val, KSH_RETURN_ERROR | 0x4); | 
						|
 	} | 
						|
  | 
						|
 	/* only x[0] is ever exported, so use vpbase */ | 
						|
 | 
						|
 | 
						|
--- ./jobs.c | 
						|
+++ ./jobs.c | 
						|
@@ -219,8 +219,7 @@ | 
						|
 static void		check_job ARGS((Job *j)); | 
						|
 static void		put_job ARGS((Job *j, int where)); | 
						|
 static void		remove_job ARGS((Job *j, const char *where)); | 
						|
-static void		kill_job ARGS((Job *j)); | 
						|
-static void	 	fill_command ARGS((char *c, int len, struct op *t)); | 
						|
+static int		kill_job ARGS((Job *j, int sig)); | 
						|
  | 
						|
 /* initialize job control */ | 
						|
 void | 
						|
@@ -294,10 +293,17 @@ | 
						|
 				    && procpid == kshpid))))) | 
						|
 		{ | 
						|
 			killed = 1; | 
						|
-			killpg(j->pgrp, SIGHUP); | 
						|
+			if (j->pgrp == 0) | 
						|
+				kill_job(j, SIGHUP); | 
						|
+			else | 
						|
+				killpg(j->pgrp, SIGHUP); | 
						|
 #ifdef JOBS | 
						|
-			if (j->state == PSTOPPED) | 
						|
-				killpg(j->pgrp, SIGCONT); | 
						|
+			if (j->state == PSTOPPED) { | 
						|
+				if (j->pgrp == 0) | 
						|
+					kill_job(j, SIGCONT); | 
						|
+				else | 
						|
+					killpg(j->pgrp, SIGCONT); | 
						|
+			} | 
						|
 #endif /* JOBS */ | 
						|
 		} | 
						|
 	} | 
						|
@@ -497,7 +503,7 @@ | 
						|
 		put_job(j, PJ_PAST_STOPPED); | 
						|
 	} | 
						|
  | 
						|
-	fill_command(p->command, sizeof(p->command), t); | 
						|
+	snptreef(p->command, sizeof(p->command), "%T", t); | 
						|
  | 
						|
 	/* create child process */ | 
						|
 	forksleep = 1; | 
						|
@@ -508,7 +514,7 @@ | 
						|
 		forksleep <<= 1; | 
						|
 	} | 
						|
 	if (i < 0) { | 
						|
-		kill_job(j); | 
						|
+		kill_job(j, SIGKILL); | 
						|
 		remove_job(j, "fork failed"); | 
						|
 #ifdef NEED_PGRP_SYNC | 
						|
 		if (j_sync_open) { | 
						|
@@ -823,11 +829,10 @@ | 
						|
 	} | 
						|
  | 
						|
 	if (j->pgrp == 0) {	/* started when !Flag(FMONITOR) */ | 
						|
-		for (p=j->proc_list; p != (Proc *) 0; p = p->next) | 
						|
-			if (kill(p->pid, sig) < 0) { | 
						|
-				bi_errorf("%s: %s", cp, strerror(errno)); | 
						|
-				rv = 1; | 
						|
-			} | 
						|
+		if (kill_job(j, sig) < 0) { | 
						|
+			bi_errorf("%s: %s", cp, strerror(errno)); | 
						|
+			rv = 1; | 
						|
+		} | 
						|
 	} else { | 
						|
 #ifdef JOBS | 
						|
 		if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP)) | 
						|
@@ -1825,50 +1830,17 @@ | 
						|
  * | 
						|
  * If jobs are compiled in then this routine expects sigchld to be blocked. | 
						|
  */ | 
						|
-static void | 
						|
-kill_job(j) | 
						|
+static int | 
						|
+kill_job(j, sig) | 
						|
 	Job	*j; | 
						|
+	int	sig; | 
						|
 { | 
						|
 	Proc	*p; | 
						|
+	int	rval = 0; | 
						|
  | 
						|
 	for (p = j->proc_list; p != (Proc *) 0; p = p->next) | 
						|
 		if (p->pid != 0) | 
						|
-			(void) kill(p->pid, SIGKILL); | 
						|
-} | 
						|
- | 
						|
-/* put a more useful name on a process than snptreef does (in certain cases) */ | 
						|
-static void | 
						|
-fill_command(c, len, t) | 
						|
-	char		*c; | 
						|
-	int		len; | 
						|
-	struct op	*t; | 
						|
-{ | 
						|
-	int		alen; | 
						|
-	char		**ap; | 
						|
- | 
						|
-	if (t->type == TEXEC || t->type == TCOM) { | 
						|
-		/* Causes problems when set -u is in effect, can also | 
						|
-		   cause problems when array indices evaluated (may have | 
						|
-		   side effects, eg, assignment, incr, etc.) | 
						|
-		if (t->type == TCOM) | 
						|
-			ap = eval(t->args, DOBLANK|DONTRUNCOMMAND); | 
						|
-		else | 
						|
-		*/ | 
						|
-		ap = t->args; | 
						|
-		--len; /* save room for the null */ | 
						|
-		while (len > 0 && *ap != (char *) 0) { | 
						|
-			alen = strlen(*ap); | 
						|
-			if (alen > len) | 
						|
-				alen = len; | 
						|
-			memcpy(c, *ap, alen); | 
						|
-			c += alen; | 
						|
-			len -= alen; | 
						|
-			if (len > 0) { | 
						|
-				*c++ = ' '; len--; | 
						|
-			} | 
						|
-			ap++; | 
						|
-		} | 
						|
-		*c = '\0'; | 
						|
-	} else | 
						|
-		snptreef(c, len, "%T", t); | 
						|
+			if (kill(p->pid, sig) < 0) | 
						|
+				rval = -1; | 
						|
+	return rval; | 
						|
 } | 
						|
 | 
						|
 | 
						|
 |