Subject: Trouble with kermit scripts on current.
To: None <current-users@NetBSD.ORG>
From: Douglas Thomas Crosher <dtc@scrooge.ee.swin.oz.au>
List: current-users
Date: 06/27/1995 21:09:33
I have just upgraded to a current system, from an April 30 system, and
found that my Kermit scripts have been getting stuck. I'm not sure if
it is a problem in Kermit, with my setup, or with NetBSD itself.

I have a i486-33, with two 16550 ports, with a modem on tty01, and a
mouse on tty00.  The mouse works OK, and kermit works OK except for
the scripts, I also use term which works fine.

eg. A Kermit script that gets stuck.
output at\13
input 2 OK\13\10

The 'at\13' characters are sent to the modem and it echos its reply,
however Kermit gets stuck on the input - it will not even time out.

It seems to be a timing related issue because if I add a sleep to the
Kermit script it works.

eg. A Kermit script that works.
output at\13
sleep 1
input 2 OK\13\10


I have a faint suspicion that it is the kernel, based on my following
analysis.

Has anyone else experienced this problem?

Do you feel it is a kernel problem or has the interface changed in a way
that would require a change to Kermit or my setup.

Note: I've tried many different ttyflag options and setups in Kermit.

-=-=-=-=-

Gdb shows that Kermit gets stuck at:
ckutio.c: 4411
tcsetattr(ttyfd, TCSADRAIN, &ttycur);

A Ktrace of this is presented below.

-=-=-=-=-

While stuck, doing a 'ps alx' shows that Kermit is stuck in a 'ttyout'
state.

-=-=-=-=-

While kermit is stuck I can do:
cat /dev/tty01
and I get the characters from the modem that Kermit has not yet read.

Further I can do:
echo aa >/dev/tty01
and the characters are sent to the modem.

Should it be possible for one process to be stuck on 'ttyout' while
another is able to write successfully?  I'm not sure but this makes me
suspicious, why would the tcsetattr(,TCSADRAIN,) not be able to drain
the output.

-=-=-=-=-=-
Ktrace of kermit getting stuck:

The relevant parts of the Kermit script were:
output atd92148619\13
minput 120 -

  1688 kermit   CALL  ioctl(0x4,TIOCGETA,0x6c1f0)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  ioctl(0x4,TIOCSETAW,0x6c1f0)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  ioctl(0x4,TIOCGETA,0xf7bfd958)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  ioctl(0x4,TIOCSETAW,0x6c1c4)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  write(0x4,0x6de7c,0xc)
  1688 kermit   GIO   fd 4 wrote 12 bytes
       "atd92148619\r"
  1688 kermit   RET   write 12/0xc
  1688 kermit   CALL  ioctl(0x4,FIONREAD,0xf7bfd9d8)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  getpgrp
  1688 kermit   RET   getpgrp 1688/0x698
  1688 kermit   CALL  ioctl(0x1,TIOCGPGRP,0xf7bfd9b4)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  ioctl(0,TIOCGETA,0xf7bfd99c)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  ioctl(0x1,TIOCGETA,0xf7bfd99c)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  sigaction(0xf,0xf7bfd9c8,0xf7bfd9bc)
  1688 kermit   RET   sigaction 0
  1688 kermit   CALL  sigaction(0x2,0xf7bfd9bc,0xf7bfd9b0)
  1688 kermit   RET   sigaction 0
  1688 kermit   CALL  sigaction(0x12,0xf7bfd9cc,0xf7bfd9c0)
  1688 kermit   RET   sigaction 0
  1688 kermit   CALL  ioctl(0x4,TIOCGETA,0x6c1f0)
  1688 kermit   RET   ioctl 0
  1688 kermit   CALL  ioctl(0x4,TIOCSETAW,0x6c1f0)

> Note: it gets stuck here, I send it a SIGINT and it continues:

  1688 kermit   PSIG  SIGINT caught handler=0x455b8 mask=0x0 code=0x0
  1688 kermit   RET   ioctl -1 errno 25 Inappropriate ioctl for device
  1688 kermit   CALL  write(0x1,0x92000,0x6)
  1688 kermit   GIO   fd 1 wrote 6 bytes
       "^C...
       "
  1688 kermit   RET   write 6

-=-=-=-=-=-

Ktrace of kermit when it does not get stuck, which is acheived by
adding a sleep to the script after the output command but before the
input command:

The relevant parts of the kermit script were:
output atd92148619\13
sleep 1
minput 120 -

  1707 kermit   CALL  ioctl(0x4,TIOCGETA,0x6c1f0)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0x4,TIOCSETAW,0x6c1f0)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0x4,TIOCGETA,0xf7bfd958)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0x4,TIOCSETAW,0x6c1c4)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  write(0x4,0x6de7c,0xc)
  1707 kermit   GIO   fd 4 wrote 12 bytes
       "atd92148619\r"
  1707 kermit   RET   write 12/0xc
  1707 kermit   CALL  ioctl(0x4,FIONREAD,0xf7bfd9d8)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  getpgrp
  1707 kermit   RET   getpgrp 1707/0x6ab
  1707 kermit   CALL  ioctl(0x1,TIOCGPGRP,0xf7bfd9b4)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0,TIOCGETA,0xf7bfd99c)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0x1,TIOCGETA,0xf7bfd99c)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  sigaction(0xf,0xf7bfd9c8,0xf7bfd9bc)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  sigaction(0x2,0xf7bfd9bc,0xf7bfd9b0)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  sigaction(0x12,0xf7bfd9cc,0xf7bfd9c0)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  ioctl(0,FIONREAD,0xf7bfd9b4)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  sigprocmask(0x1,0x2000)
  1707 kermit   RET   sigprocmask 0
  1707 kermit   CALL  sigaction(0xe,0xf7bfd994,0xf7bfd988)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  setitimer(0,0xf7bfd9b0,0xf7bfd9a0)
  1707 kermit   RET   setitimer 0
  1707 kermit   CALL  sigsuspend(0)
  1707 kermit   PSIG  SIGALRM caught handler=0x100aa76c mask=0x2000 code=0x0
  1707 kermit   RET   sigsuspend -1 errno 4 Interrupted system call
  1707 kermit   CALL  sigreturn(0xf7bfd920)
  1707 kermit   RET   sigreturn JUSTRETURN
  1707 kermit   CALL  sigaction(0xe,0xf7bfd988,0)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  sigprocmask(0x3,0)
  1707 kermit   RET   sigprocmask 8192/0x2000
  1707 kermit   CALL  setitimer(0,0xf7bfd9a0,0xf7bfd9b0)
  1707 kermit   RET   setitimer 0
  1707 kermit   CALL  ioctl(0x4,FIONREAD,0xf7bfd9d8)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  getpgrp
  1707 kermit   RET   getpgrp 1707/0x6ab
  1707 kermit   CALL  ioctl(0x1,TIOCGPGRP,0xf7bfd9b4)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0,TIOCGETA,0xf7bfd99c)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0x1,TIOCGETA,0xf7bfd99c)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  sigaction(0xf,0xf7bfd9c8,0xf7bfd9bc)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  sigaction(0x2,0xf7bfd9bc,0xf7bfd9b0)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  sigaction(0x12,0xf7bfd9cc,0xf7bfd9c0)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  ioctl(0x4,TIOCGETA,0x6c1f0)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0x4,TIOCSETAW,0x6c1f0)

> This is the point that it became stuck last time.

  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0x4,TIOCGETA,0xf7bfd904)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  ioctl(0x4,TIOCSETAW,0x6c1c4)
  1707 kermit   RET   ioctl 0
  1707 kermit   CALL  gettimeofday(0xf7bfd940,0)
  1707 kermit   RET   gettimeofday 0
  1707 kermit   CALL  sigaction(0xe,0xf7bfd92c,0xf7bfd920)
  1707 kermit   RET   sigaction 0
  1707 kermit   CALL  setitimer(0,0xf7bfd924,0xf7bfd914)
  1707 kermit   RET   setitimer 0
  1707 kermit   CALL  sigprocmask(0x1,0)
  1707 kermit   RET   sigprocmask 0
  1707 kermit   CALL  read(0x4,0x6c2d4,0x100)
  1707 kermit   GIO   fd 4 read 60 bytes
       "AT&F\r\r
	OK\r
	AT \\V8 X5 &E2 %C1 S0=0 &K0 &C0\r\r
	OK\r
	atd92148619\r"
  1707 kermit   RET   read 60/0x3c

-=-=-=-=-