Package: pdksh
Version: 5.2.14-16

I work for IBM and we have been shipping an fixed version of pdksh for
one of our products. One of our customers is providing that fix to
SuSE so I am providing it to Redhat and Debian.

Here is the problem description from the developer:

The gist of the problem was that the shell was waiting for tty input
in a non-interactive script. The result was that the shell would hang
waiting for input that was never coming. I remember writing an example
that ran fine on other ksh's, but failed on pdksh. Sent the example to
the maintainer of pdksh and he suggested the fix that I put in. If I
remember right, it was basically adding a check for if it was an
interactive shell or not. This got us past the problem and was
supposed to end up in the official pdksh. That was a number of years
ago and still no sign of the fix :(

Here is the reproduce scenario:

two scripts:

::::::::::::::
test1.ksh
::::::::::::::
#!/bin/ksh

./test2.ksh&


::::::::::::::
test2.ksh
::::::::::::::
#!/bin/ksh

set -m
xclock &

exit 1

chmod both scripts +x
NOTE: Make sure you have your DISPLAY variable properly set.
Run: ./test1.ksh &

You should get a "Stopped" message(you may have to hit enter to see
it), the xclock command should  not run and both scripts should be
left running(you will need to kill them). This is what happens during
the installation, it basically stops.

A couple of things to note at this point:
1) if you kill test1.ksh, test2.ksh will immediately start hogging the cpu
2) test2.ksh will become parented by init(1) (it was originally
parented by pidof(test1.ksh))

Once you kill test2.ksh everything should return to normal.

On a normally(properly) working ksh, the scripts should both finish
and only the xclock should be left running. This is the response I got
from Solaris, AIX and the fixed pdksh.

Here is the diff from the original 5.2.14 code downloaded from the
pdksh website:
--- jobs.c      2001-10-27 15:31:57.000000000 -0400
+++ /home/possum/pdksh-5.2.14/jobs.c    1999-07-13 12:50:56.000000000 -0400
@@ -334,17 +334,12 @@
        int i;

        if (Flag(FMONITOR)) {
-               int use_tty;
-               if (Flag(FTALKING)) {
-                       /* Don't call get_tty() 'til we own the tty
process        group */
-                       use_tty = 1;
-                       tty_init(FALSE);
-               } else
-                       use_tty = 0;
+               /* Don't call get_tty() 'til we own the tty process group */
+               tty_init(FALSE);

 # ifdef TTY_PGRP
                /* no controlling tty, no SIGT* */
-               ttypgrp_ok = use_tty && tty_fd >= 0 && tty_devtty;
+               ttypgrp_ok = tty_fd >= 0 && tty_devtty;

                if (ttypgrp_ok && (our_pgrp = getpgID()) < 0) {
                        warningf(FALSE, "j_init: getpgrp() failed: %s",
@@ -400,10 +395,8 @@
                                        strerror(errno));
                }
 #  endif /* NTTYDISC && TIOCSETD */
-               if (Flag(FTALKING)) {
-                       if (!ttypgrp_ok)
-                               warningf(FALSE, "warning: won't have
full job      control");
-               }
+               if (!ttypgrp_ok)
+                       warningf(FALSE, "warning: won't have full job control");
 # endif /* TTY_PGRP */
                if (tty_fd >= 0)
                        get_tty(tty_fd, &tty_state);

I will be happy to provide this in a file if you would like.

Please let me know if there is any additional information that you need.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to