TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Denis Tonn
from: Jonathan de Boyne Pollard
date: 1996-11-09 09:50:56
subject: watcom and warp

DT>
  > JdeBP> As reported by DosSetRelMaxFH with a delta of 0, the default is 50 o
  > JdeBP> OS/2 Warp 3.0, not 20.  The CP Reference is wrong.
  >
  > I don't have a compiler handy (something had to give to install Warp
  > 4 on this laptop) - so I can't duplicate your exact test at the
  > moment.
DT>

//
//  ************************************************************************
//                      Investigate file handle availability
//    (c) Copyright 1995 Jonathan de Boyne Pollard.  All rights reserved.
//  ************************************************************************
//

//
//  Permission is hereby granted to post, steal and abuse this code for your
// own purposes to your heart's content, as long as you realise that I take
// no responsibility whatsoever for what it does to your machine, data, cat,
// or marital status.
//

//
//  Some device drivers open file handles at boot time and do not close them.
//  These file handles are inherited by all processes within the system, and
//  cause IBM's resource compiler to fail with a C1015.  This program prints
//  information on the maximum number of file handles available, the current
//  number of open files, and what each file handle is open to.
//

#define INCL_DOS
#include 
#include 

int
main ( int, char ** )
{
    unsigned long maxhandles = 0, openhandles = 0 ;
    long delta = 0 ;

    DosSetRelMaxFH(&delta, &maxhandles) ;

    cout << "There are " << maxhandles
      << " file handles available to this process." << endl ;

    for (unsigned long h = 0 ; h < maxhandles ; ++h) {
        unsigned long type = 0, attrword = 0 ;
        if (!DosQueryHType(h, &type, &attrword)) {
            ++openhandles ;
            cout << "File handle " << h <<
": " ;

            //
            //  If your C++ compiler doesn't support binary literals,
            //  as MetaWare High C++ for OS/2 does, then you will need
            //  to alter the next three lines.
            //

            if (type & 0x2x1000_0000_0000_0000) cout <<
"Network, " ;
            if (type & 0x2x0100_0000_0000_0000) cout <<
"Protected, " ;

            switch (type & 0x2x0000_0000_1111_1111) {
                default:    cout << "Unknown type."
<< endl ; break ;
                case 0:     cout << "Disk file." <<
endl ; break ;
                case 1:     cout << "Character device."
<< endl ; break ;
                case 2:     cout << "Pipe." << endl ; break ;
            }
        }
    }

    cout << "There are " << openhandles
      << " handles currently open." << endl ;

    return 0 ;
}

  > JdeBP <
___
 X MegaMail 2.10 #0:

--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)
SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1
@PATH: 440/4 141/209 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.