cc:  [email protected]  [EMAIL PROTECTED]
Subject: Re: Re: [ast-developers] Endless loop in SHLVL 2
--------

> > The problem is in the module sh/xec.c in the function sh_ntfork().
> > 
> > The problem is that the variable jobwasset is reset to its
> > original value after a longjmp.  The value of jobwassset is
> > initialized to 0 at the beginning.  After the setjmp, the value
> > is set to 1.   Since this is not a register variable, I would
> > expect that the value would remain 1 after the longjmp.
> > 
> > I changed to code to declare jobwasset to be volatile but I
> > don't beleive that this is required by the C standard.
> > 
> > As a result, the SIGTTOU signal was not being set back to SIG_IGN
> > which caused a problem with tty_set().
> 
> Hmmm ... AFAICS from the code of sh_ntfork() the problem is the
> failed part of the pipe ``echo | les''  ... the builtin `echo'
> pipes a newline into stdin of `les' but the command `les' does
> not exist. This leads to an error which will be handled within
> 
>     if(spawnpid < 0) switch(errno=shp->path_err)
>     {
>         case ENOENT:
>             errormsg(SH_DICT,ERROR_system(ERROR_NOENT),e_found+4);
>         default:
>             errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_exec+4);
>     }
> 
> in other words the sub shell spawned for executing `les' fails and
> exists without reseting the terminal before.   I don't know if the
> errormsg() will be executed with ERROR_system(ERROR_NOENT) the
> longjmp will be satisfied.  This was the reason for me to add the
> tty signal reset before the switch().  The problem occurs *only* if
> the last command fails, if the last command is found then the
> longjmp works as expected:
> 

The longjmp is invoked by errormsg() after it outputs the error message.
The variable jobwasset is set to 1 when I disable
SIGTTOU and SIGTTIN.  If there wasn't an error then longjmp()
would not have been called and jobwasset would have been 1.
When longjmp is called, jobwasset is 0.  Since jobwasset is not
a register variable, I don't believe that this should have happened.
The problem does not happen when compiled with -g.  I changed the declaration
of jobwasset to volatile and that fixed the problem.

David Korn
[EMAIL PROTECTED]
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to