On Wed, Nov 28, 2007 at 01:55:24PM -0500, David Korn wrote:
> cc:  [EMAIL PROTECTED]
> Subject: Re: Re: [ast-developers] Endless loop in SHLVL 2
> --------
> 
> I have tracked this problem down to a compiler bug or a misundersanding
> on my part.
> 
> 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:

   /suse/werner> ksh
   [EMAIL PROTECTED]:/suse/werner> PATH=/usr/local/bin:/usr/bin:/bin:.
   [EMAIL PROTECTED]:/suse/werner> echo | does_not_exit
   ksh: does_not_exit: not found [No such file or directory]

   [1]  + 11962 Suspended (tty output)        ksh
   /suse/werner> fg
   [EMAIL PROTECTED]:/suse/werner> exit

   /suse/werner> ksh
   [EMAIL PROTECTED]:/suse/werner> PATH=/usr/local/bin:/usr/bin:/bin:.
   [EMAIL PROTECTED]:/suse/werner> echo | less                       
   [EMAIL PROTECTED]:/suse/werner> exit


      Werner

-- 
 Dr. Werner Fink <[EMAIL PROTECTED]>
 SuSE LINUX Products GmbH,  Maxfeldstrasse 5,  Nuernberg,  Germany
 GF: Markus Rex,  HRB 16746 (AG Nuernberg)
 phone: +49-911-740-53-0,  fax: +49-911-3206727,  www.opensuse.org
------------------------------------------------------------------
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to