File ksh93-foreground-prgrp.dif of Package ksh

--- src/cmd/ksh93/sh/jobs.c
+++ src/cmd/ksh93/sh/jobs.c	2014-02-18 14:28:42.330940622 +0000
@@ -894,7 +894,9 @@ static void job_reset(register struct pr
 	Shell_t *shp = pw->p_shp;
 	/* save the terminal state for current job */
 #ifdef SIGTSTP
-	job_fgrp(pw,tcgetpgrp(job.fd));
+	pid_t tgrp;
+	if((tgrp=tcgetpgrp(job.fd))!=job.mypid)
+		job_fgrp(pw,tgrp);
 	if(sh_isoption(shp,SH_INTERACTIVE) && tcsetpgrp(job.fd,job.mypid) !=0)
 		return;
 #endif	/* SIGTSTP */