zsh-workers
 help / color / mirror / code / Atom feed
* Re: zsh-3.0.3: another problem in Src/jobs.c
@ 1997-06-23 10:51 SUZUKI Hisao
  1997-06-23 15:22 ` Zoltan Hidvegi
  0 siblings, 1 reply; 14+ messages in thread
From: SUZUKI Hisao @ 1997-06-23 10:51 UTC (permalink / raw)
  To: hzoli, zsh-workers

K"os"on"om szepen, Zoltan ur es zsh-workers!

Thank you for releasing the debugged zsh so promptly.  I got
zsh-3.0.4.tar.gz just now.  I see it works almost finely and
Src/jobs.c has changed in lines ca 157 from

	if (shout && !ttyfrozen && !jn->stty_in_env)
	     gettyinfo(&shttyinfo);
to
	if (shout && !ttyfrozen && !jn->stty_in_env &&
	    job == thisjob && !somestopped)
	    gettyinfo(&shttyinfo);

Yes, it is substantially the same patch as that of my message
<9706192332.AA00517@oz.fantasy.otsl.oki.co.jp> sent you on June
20 (or June 19 in GMT).  You have made a right choice at last
for the present implementation for the time being! (I knock on
wood here :-)

However, I am afraid I must say something still goes wrong.  Try
this:
	% emacs -nw &
	% fg
	[type ^X^C to terminate the emacs]
	% stty

	[Note: this is not artificial.  When you forget to set
	 DISPLAY, you will be put in the same situation.]

As you see, the tty setting remains sane as long as you suspend
or continue the emacs job.  Once you terminate the job, the tty
setting goes bad.

If solely my patch of June 20 had applied, then this is not
happend when you _once_ suspend the "fg"ed emacs job before
terminate it.  Now that you also changed Src/jobs.c from

	if (jn->stty_in_env && !jn->ty) {
	    jn->ty = (struct ttyinfo *) zalloc(sizeof(struct ttyinfo));
to
	if (shout && job == thisjob) {
	    if (!jn->ty)
		jn->ty = (struct ttyinfo *) zalloc(sizeof(struct ttyinfo));

in lines 140-142, the problem was revealed.  In zsh-3.0.4, it
happens whether you have once suspended the job or not.

--
Hisao Suzuki <suzuki@otsl.oki.co.jp>


^ permalink raw reply	[flat|nested] 14+ messages in thread
[parent not found: <3.0.1.32.19970624091754.01331150@home.incontext.com>]
* zsh-3.0.3: another problem in Src/jobs.c
@ 1997-06-19  6:24 SUZUKI Hisao
  1997-06-19  7:04 ` Zoltan Hidvegi
  1997-06-19  8:58 ` Peter Stephenson
  0 siblings, 2 replies; 14+ messages in thread
From: SUZUKI Hisao @ 1997-06-19  6:24 UTC (permalink / raw)
  To: zsh-workers

Jo napot kivanok!
(...or "Jo reggelt kivanok")

	I reported a problem of zsh-3.0.3/Src/jobs.c by e-mail
<9706180710.AA10798@oz.fantasy.otsl.oki.co.jp> yesterday.  Now I
found another problem.  It is like this:

	ares:~% stty
	speed 9600 baud; line = 0;
	intr = ^G; erase = ^H;
	-brkint ixoff -imaxbel
	-iexten -echoctl
	ares:~% emacs -nw &
	[1] 2537
	ares:~% 
	[1]  + suspended (tty output)  emacs -nw
	ares:~% fg
	[1]  + continued  emacs -nw
	
	zsh: suspended  emacs -nw
	ares:~% stty
	speed 9600 baud; line = 0;
	intr = ^G; quit = <undef>; erase = ^H; susp = <undef>; lnext = <undef>;
	flush = <undef>;
	-brkint inlcr ixoff -imaxbel
	-iexten -echoctl

This is similar to what I reported yesterday in that the tty
setting is modified unexpectedly by a background job.  Really
they are the same _annoying_ problem of the same cause in a
sense.
	Again, for the time being, I made a hack to fix it
rather in a clean way (at least I think so :-) this time.  I
hope the problem will be fixed soon in any way.

----------------------------------------------------------------
*** zsh-3.0.3/Src/jobs.c.ORIG	Tue Jun  3 05:11:27 1997
--- zsh-3.0.3/Src/jobs.c	Thu Jun 19 02:35:37 1997
***************
*** 121,135 ****
      int job;
      int val = 0, status = 0;
      int somestopped = 0, inforeground = 0;
  
      for (pn = jn->procs; pn; pn = pn->next) {
  	if (pn->status == SP_RUNNING)      /* some processes in this job are running       */
  	    return;                        /* so no need to update job table entry         */
  	if (WIFSTOPPED(pn->status))        /* some processes are stopped                   */
  	    somestopped = 1;               /* so job is not done, but entry needs updating */
! 	if (!pn->next)                     /* last job in pipeline determines exit status  */
  	    val = (WIFSIGNALED(pn->status)) ? 0200 | WTERMSIG(pn->status) :
  		WEXITSTATUS(pn->status);
  	if (pn->pid == jn->gleader)        /* if this process is process group leader      */
  	    status = pn->status;
      }
--- 121,140 ----
      int job;
      int val = 0, status = 0;
      int somestopped = 0, inforeground = 0;
+     pid_t pgrp = -1;
+     int is_foreground = 0;	/* is this job in the foreground actually? */
+     int is_stopped = 0;		/* is this job stopped? */
  
      for (pn = jn->procs; pn; pn = pn->next) {
  	if (pn->status == SP_RUNNING)      /* some processes in this job are running       */
  	    return;                        /* so no need to update job table entry         */
  	if (WIFSTOPPED(pn->status))        /* some processes are stopped                   */
  	    somestopped = 1;               /* so job is not done, but entry needs updating */
! 	if (!pn->next) {  /* last job in pipeline determines exit status  */
  	    val = (WIFSIGNALED(pn->status)) ? 0200 | WTERMSIG(pn->status) :
  		WEXITSTATUS(pn->status);
+ 	    is_stopped = WIFSTOPPED(pn->status);
+ 	}
  	if (pn->pid == jn->gleader)        /* if this process is process group leader      */
  	    status = pn->status;
      }
***************
*** 154,168 ****
  	}
      }
  
!     if (shout && !ttyfrozen && !jn->stty_in_env)
! 	gettyinfo(&shttyinfo);
! 
      if (isset(MONITOR)) {
! 	pid_t pgrp = gettygrp();           /* get process group of tty      */
! 
  	/* is this job in the foreground of an interactive shell? */
! 	if (mypgrp != pgrp && inforeground &&
! 	    (jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1))) {
  	    attachtty(mypgrp);
  	    adjustwinsize();   /* check window size and adjust if necessary */
  	}
--- 159,179 ----
  	}
      }
  
!     if (shout && !ttyfrozen && !jn->stty_in_env && !is_stopped) {
! 	pgrp = gettygrp();	/* get process group of tty */
! 	is_foreground = (jn->gleader == pgrp ||
! 			 (pgrp > 1 && kill(-pgrp, 0) == -1));
! 	if (is_foreground)
! 	    gettyinfo(&shttyinfo);
!     }
      if (isset(MONITOR)) {
! 	if (pgrp == -1) {
! 	    pgrp = gettygrp();
! 	    is_foreground = (jn->gleader == pgrp ||
! 			     (pgrp > 1 && kill(-pgrp, 0) == -1));
! 	}
  	/* is this job in the foreground of an interactive shell? */
! 	if (mypgrp != pgrp && inforeground && is_foreground) {
  	    attachtty(mypgrp);
  	    adjustwinsize();   /* check window size and adjust if necessary */
  	}
----------------------------------------------------------------

Regards,

Hisao Suzuki <suzuki@otsl.oki.co.jp>


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~1997-06-25  3:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-23 10:51 zsh-3.0.3: another problem in Src/jobs.c SUZUKI Hisao
1997-06-23 15:22 ` Zoltan Hidvegi
1997-06-24  2:05   ` SUZUKI Hisao
1997-06-24  2:52     ` Zoltan Hidvegi
1997-06-24 11:56       ` SUZUKI Hisao
     [not found] <3.0.1.32.19970624091754.01331150@home.incontext.com>
1997-06-25  1:10 ` SUZUKI Hisao
1997-06-25  3:10   ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
1997-06-19  6:24 SUZUKI Hisao
1997-06-19  7:04 ` Zoltan Hidvegi
1997-06-19  7:26   ` Andrei Tcherepanov
1997-06-19 23:32   ` SUZUKI Hisao
1997-06-20  3:45     ` Zoltan Hidvegi
1997-06-20  8:20       ` SUZUKI Hisao
1997-06-19  8:58 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).