🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.sgi.bugs
1 messages
1 total messages Started by Frederic Hemmer Mon, 21 Dec 1992 17:24
close() BUG ?
#21
Author: Frederic Hemmer
Date: Mon, 21 Dec 1992 17:24
81 lines
2378 bytes
Perhaps I'm getting crazy (or tired), but I've a little problem
with close() used with ioctl(TIOCGWINSZ).

The following program :

#include <stdio.h>
#include <unistd.h>
#include <sys/termio.h>
#include <sys/types.h>
#include <fcntl.h>


/*
 * Getting terminal window size.
 */
int termwinsiz(col,row)
        int *col ;
        int *row ;
{
        int             term ;          /* Terminal identifier  */      
        struct winsize  win  ;          /* Window structure     */

        if ( (term= open("/dev/tty",O_RDWR)) == -1 ) {
                return -1 ;
        }
        if ( ioctl(term,TIOCGWINSZ,&win) == -1 ) {
                return -1 ;
        }
        if ( close(term) == -1 ) {
                return -1 ;
        }
        *col= win.ws_col ;
        *row= win.ws_row ;

        return 0 ;
}

main()  {
        int col;
        int row;

        if (termwinsiz(&col, &row) == -1)       {
                perror("unable to get terminal size");
        }
        else    {
                printf("Your window size is %dX%d\n", col, row);
        }
        exit (0);
}

Gives the following output on 4.0.5 (I believe it worked fine with 3):

unable to get terminal size: No such device

It is the close() syscall who complains.

Note that if I replace the close invocation by :

#if (defined(sgi) && defined(__EXTENSIONS__)) /* detects Irirx 4.0.5 */
        (void) close(term);
#else
        if ( close(term) == -1 ) {
                return -1 ;
        }
#endif /* sgi && __EXTENSIONS */

The output is fine :

	Your window size is 81X26

The same program worked without any problem on many systems
(sun, aix, hp, cray, ultrix ...)

Can somebody help ?

-- 
Frederic Hemmer                          email: hemmer@sun2.cern.ch
European Laboratory for Particle Physics bitnet: hemmer at cernvm
Computers and Networks division          phone: +41-22-7676104
CH-1211 Geneva 23 - Switzerland          fax:   +41-22-7677155
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads