[comp.windows.x] X under sunview broken under SunOS4.1.1

kjg@bcat1.prime.com (Ken Gartner) (02/13/91)

    I have a problem running X11R4 on top of sunview under SUNOS 4.1.1.   The
exact same executables work fine under SUNOS4.0.3.  I do not know that much about
X so please be gentle...

    Basically, standalone X11R4 works on Sparc2 and SUN3/60 machines under 4.1.1,
but if X is invoked under sunview as follows, the following happens:

     foo1>  trace -o foo X :0 -dev /dev/bwtwo0

     WIN ioctl number 80706728: Device Busy
      sunOpenFrameBuffer: Can't open new screen on /dev/bwtwo0.

     Fatal server bug!
     no screens found

  [ The same thing happens if X is compiled on a 4.1.1 machine. ]

    The error is generated in sunInit.c in server/ddx/sun:

...
        /*
         * If no device was specified on the command line, open the window
         * specified in WINDOW_PARENT.  If a device was specified, open a
         * new screen on that device and use it as a parent window.
         */

        if ( devsw ) {
            bzero( (caddr_t)&newScreen, sizeof(newScreen) );
            strcpy( newScreen.scr_fbname, name );
            newScreen.scr_flags |= SCR_TOGGLEENABLE;
-->         if ( (parentFd = win_screennew( &newScreen )) < 0 ) {
                ErrorF( "sunOpenFrameBuffer: Can't open new screen on %s.\n",
                    name );
                return( -1 );

...
    
  The problem seems to be with the [win_screennew] routine in sunInit.c,
which does an ioctl on /dev/win5.  In the working case, this results in
a SIGWINCH (28), in the bad case the result is EBUSY.  A little examination
of the ioctl include files reveals:

      open ("/dev/win5", 0200002, 0) = 8
      ioctl (8, 0x80706728, 0xdfff710) = -1 EBUSY (Device busy)

   in sunwindow/win_ioctl.h:

     80 00 00 00    |
        70 00 00    |
           g  00    |
              40  <-|

#define WINSCREENNEW    _IOW(g, 40, struct usrdesktop)
        /* Copies in usrdesktop and installs the calling window as its root.
        The root window is opened before making this call (obviously).
        Udt_scr.scr_name is made available to other window processes via
        WINSCREENGET so that they can pass it to pr_open during pixrect
        creation.  The root's rect size is set to the size of scr_rect. */

   in sys/ioccom.h:

#define _IOW(x,y,t)     (_IOC_IN|((sizeof(t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)
#define _IOC_IN         0x80000000      /* copy in parameters */
#define _IOCPARM_MASK   0xff            /* parameters must be < 256 bytes */


  The big questions are: 1) How does this ioctl return EBUSY? and 2)
    what changed in SUNOS4.1.1 to  cause this (will I see this in other
    programs I have ...).


   Thank you.

   kjg

-- 
Kenneth J. Gartner                      |   kjg@s49.prime.com
Prime Computer (CPU Group)              |   1-508-620-2800 x3287
500 Old Connecticut Path, MS 10A-04
Framingham Mass, 01701

"Cursedbehewho thinks my opinions reflect Prime Official policy"