[comp.unix.aux] Console I/O in X on A/UX 1.1

km@mathcs.emory.edu (Ken Mandelberg) (06/22/89)

I am having trouble understanding what is going on with console i/o
when running X on A/UX 1.1.

The default X setup does an "xinit xterm -T console -e .x11start  ...."
which starts up one xterm that runs a startup script of other clients.
The "T" just titles the window. Magically on A/UX 1.1, this causes all
/dev/console I/O to go to this xterm's pty apparently including some
old console messages. I don't know why.

On SunOS and a few other BSD style Unix workstations, there is an ioctl
TIOCCONS, that has exactly this effect (without the history of course).
In fact xterm has a documented flag "-C" that exploits this where
available.  On A/UX 1.1, there is no documented TIOCCONS, and the -C
flag is not parsed in xterm (I recall an ifdef TIOCCONS in the
generic xterm source).

So A/UX is doing something else.

The reason this is of interest is in using xdm instead of xinit.  The
sample xdm xsession does not create a console xterm. Since I don't know
how xinit does the console trick, I don't know how to make xdm do it.

I've looked in a few obvious places. There's no reference to a
TIOCCONS type ioctl in the console or termio man pages, or in
any of the X documentation I scanned.
-- 
Ken Mandelberg      | km@mathcs.emory.edu          PREFERRED
Emory University    | {decvax,gatech}!emory!km     UUCP 
Dept of Math and CS | km@emory.bitnet              NON-DOMAIN BITNET  
Atlanta, GA 30322   | Phone: (404) 727-7963

john@unisoft.UUCP (John Sovereign) (06/24/89)

In article <4167@emory.mathcs.emory.edu> km@mathcs.emory.edu (Ken Mandelberg) writes:
>I am having trouble understanding what is going on with console i/o
>when running X on A/UX 1.1.

Yes, these are undocumented features of A/UX 1.1.  Maybe this means they will
go away in the future....  

Two separate features exist.  First, there's a pseudo-device which allows
access to kernel printf's, /dev/oldmsgs.  This driver is similar to the
osm driver that's been around System V for sometim.  The old beta version
of X11R2 which I'm still running does a "tail -f /dev/oldmsgs" in the
startup script.  This also seems to disable kernel printf's output to
/dev/console.

Second, there's an ioctl in the console streams driver which diverts output
coming from user processes to this pseudo-device.  Used together, these
two features should provide the capability you want.  The following code
demonstrates this streams ioctl; if you haven't used System V streams this
will look a little weird....

#include <sys/video.h>
#include <sys/stropts.h>

main(argc, argv)
int argc;
char **argv;
{
        struct strioctl i;

        if (atoi(*++argv))
                i.ic_cmd = CONS_REDIRECT;
        else
                i.ic_cmd = CONS_UNDIRECT;
        i.ic_timout = i.ic_dp = i.ic_len = 0;

        if (ioctl(0, I_STR, &i) == -1) {
                perror("ioctl");
                exit(1);
        }

        exit(0);
}

The usage of this program should be something like "redirect 1 < /dev/console"
to turn on redirection and "redirect 0 < /dev/console" to turn it off.

>Ken Mandelberg      | km@mathcs.emory.edu          PREFERRED
>Emory University    | {decvax,gatech}!emory!km     UUCP 
>Dept of Math and CS | km@emory.bitnet              NON-DOMAIN BITNET  
>Atlanta, GA 30322   | Phone: (404) 727-7963

John Sovereign		| "Hold Quality undefined.  That's the secret."
UniSoft Corporation	|	-- Robert Pirsig,
uunet!unisoft!john	|	Zen and the Art of Motorcycle Maintenance