[comp.sys.sun] cannot start cmdtool on NCD X-terminal under SunOS 4.1

sitongia@hao.ucar.edu (Leonard Sitongia) (06/05/91)

I've been using an NCD X-19 terminal with xdm from MIT X11R4 displaying a
cmdtool from OpenWindows 2.0 served from a Sun-4/280 running SunOS 4.0.3 for 
some time.  It is simply exec'd from the .openwin-menu.

After I upgraded the Sun to SunOS 4.1, I have been unable to run the
cmdtool on the Sun to display directly on the X terminal.  If I exec a
cmdtool which rlogins to the same Sun (in other words the same cmdtool
which fails but in this case does a rlogin to the same system that the 
cmdtool is running on), it suceeds (using two ttyp?'s, though).

The failing cmdtool appears normal, in that it opens ok, and echos input,
but will not execute input.

In any case, when the cmdtool is started up, the xdm-errors reports:

ttysw-TIOCSPGRP: Interrupted system call

The only discernible difference is from tracing the two cmdtools.

In the case of the cmdtool which is rlogin'd, here is how it reads (I typed
in the letter "a"):

select (256, 0xf7fff5f0, 0xf7fff5d0, 0xf7fff5b0, 0xf7746894) = 0
gettimeofday (0x197d4, 0) = 0
write (3, "".., 168) = 168
ioctl (3, 0x4004667f, 0xf7fff2dc) = 0
gettimeofday (0xf7fff4b0, 0) = 0
setitimer (0, 0xf7fff420, 0) = 0
select (256, 0xf7fff5f0, 0xf7fff5d0, 0xf7fff5b0, 0) = 1
ioctl (3, 0x4004667f, 0xf7ffef4c) = 0
read (3, "".., 32) = 32
ioctl (3, 0x4004667f, 0xf7ffefe4) = 0
write (3, "".., 92) = 92
ioctl (3, 0x4004667f, 0xf7fff2dc) = 0
select (256, 0xf7fff5f0, 0xf7fff5d0, 0xf7fff5b0, 0) = 1
write (4, "a", 1) = 1
ioctl (3, 0x4004667f, 0xf7fff2dc) = 0
select (256, 0xf7fff5f0, 0xf7fff5d0, 0xf7fff5b0, 0) = 2
readv (4, 0xf774bd70, 2) = 2
gettimeofday (0xa9a0, 0) = 0
ioctl (3, 0x4004667f, 0xf7ffef4c) = 0
read (3, "".., 32) = 32
ioctl (3, 0x4004667f, 0xf7ffefe4) = 0
write (3, "".., 76) = 76
ioctl (3, 0x4004667f, 0xf7fff2dc) = 0
gettimeofday (0xf7fff4b0, 0) = 0
setitimer (0, 0xf7fff420, 0) = 0
select (256, 0xf7fff5f0, 0xf7fff5d0, 0xf7fff5b0, 0xf7746894) =

But the cmdtool which is simply exec'd is doing this (again, I typed 
in "a"):

select (256, 0xf7fff5f8, 0xf7fff5d8, 0xf7fff5b8, 0) = 1
ioctl (3, 0x4004667f, 0xf7ffef54) = 0
read (3, "".., 32) = 32
write (3, "".., 96) = 96
read (3, 0xf7ffdba4, 32) = -1 EWOULDBLOCK (Operation would block)
select (4, 0xf7ffda70, 0, 0, 0) = 1
read (3, "".., 32) = 32
read (3, "".., 28) = 28
read (3, "".., 168) = 168
read (3, "".., 2688) = 1820
read (3, "".., 868) = 868
ioctl (3, 0x4004667f, 0xf7ffefec) = 0
write (3, "".., 188) = 188
ioctl (3, 0x4004667f, 0xf7fff2e4) = 0
read (3, "".., 32) = 32
ioctl (3, 0x4004667f, 0xf7fff1fc) = 0
ioctl (3, 0x4004667f, 0xf7fff2e4) = 0
select (256, 0xf7fff5f8, 0xf7fff5d8, 0xf7fff5b8, 0) =

Can someone give me some insight into what is going wrong?

Thanks.

-Leonard E. Sitongia           sitongia@ncar.ucar.edu
System Manager                 (303) 497-1509
High Altitude Observatory      P.O. Box 3000 Boulder CO  80307

andrewr@ucs.adelaide.edu.au (Andrew Rutherford) (06/05/91)

In article <2922@brchh104.bnr.ca> sitongia@hao.ucar.edu (Leonard Sitongia) writes:
>I've been using an NCD X-19 terminal with xdm from MIT X11R4 displaying a
>cmdtool from OpenWindows 2.0 served from a Sun-4/280 running SunOS 4.0.3 for 
>some time.  It is simply exec'd from the .openwin-menu.

[ ... Some stuff deleted ... ]

>The failing cmdtool appears normal, in that it opens ok, and echos input,
>but will not execute input.
>
>In any case, when the cmdtool is started up, the xdm-errors reports:
>
>ttysw-TIOCSPGRP: Interrupted system call

I think we need this stuck in an FAQ. It's the kind of problem that people
  ask in newsgroups they don't often have time to read :-(

Anyway, the answer to your question is to invoke the cmdtool as

  setsid cmdtool <<options>>

The reason for this is that cmdtool does some funny stuff with process
  groups, and falls in a heap if it's not invoked from a terminal. Usually,
  this is OK as the process can trace it's ancestry back to a login session
  on the console. Xdm, however, divests itself of controlling terminals,
  and cmdtool fails.

There are three ways around this:
  - Start cmdtool up from another login (as you've discovered)
  - Start cmdtool up as "setsid cmdtool"
  - Use xterm.

Personally, I prefer the latter, as then I can use my cursor keys in tcsh
  and have scroll bars at the same time.

Hope this helps,
		Andrew.
--
Andrew Rutherford                        andrewr@ucs.adelaide.edu.au
+61 8 228 5661                  Real Programmers always confuse Christmas and
Room 1069, Adelaide Uni	            Halloween because OCT 31 == DEC 25 !