Announcement

Collapse
No announcement yet.

SHELL causes GPF when more than 14 files are open

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SHELL causes GPF when more than 14 files are open

    Hello Everyone
    I have discovered that a GPF occurs using SHELL when more than 14 files are open.
    I have found the problem only with W95/98 and ME. I have done tests
    on W3.11/XP/2000 and found no problem.
    My CONFIG.SYS file contains the setting files=120

    $Compile EXE "Test.EXE"
    CLS
    X& = SETMEM(- 6400) ' free 100*64 bytes for file handles

    ' ************* Allow up to 50 file handles
    ! Push DS
    ! Mov BX,50
    ! Mov AH,&H67
    ! Int &H21
    ! Pop DS
    ' *******************************

    Z = Val(Command$)
    If Z = 0 Then Z = 14

    For X = 1 To Z
    OPEN "TEST"+Trim$(Str$(X)) FOR OUTPUT AS #X
    ? X;
    Next X

    SHELL
    CLOSE
    END

    Anyone expeienced this?
    Thanks for your help in advance
    Bernie


    ------------------
    [email protected]

    [This message has been edited by Bernie Lazette (edited March 19, 2002).]
    [email protected]

  • #2
    Interesting. Sounds like the O/S is running out of handles to provide to the command-interpreter (which will usually require at least 5 handles for itself). Have you tried that in plain DOS?

    Anyway, the best solution is probably "dont do that".... close (some or all of) the files before the SHELL.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Anyway, the best solution is probably "dont do that".... close (some or all of) the files before the SHELL.
      Maybe it's an old wives tale, but I thought it was considered "good programming practice" to <U>never</U> SHELL with files open????

      MCM


      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        It may be a minor miracle that this technique works at all. I have my doubts
        that PB/DOS was designed to work with more than 20 file handles, total.
        Otherwise, that little bit of assembly language would not be needed.

        Problem with supporting more than 20 file handles is, it moves the location
        of the DOS handle table out of the PSP into main memory. I'd guess this is
        not compatible with the memory compaction required before SHELL, unless
        special coding is done. Extended file handle tables weren't allowed
        until DOS 3.3 and were buggy then-- I don't recall any compiler providing
        support for them.

        I'd suggest using a library that was specifically written for extended
        file handles, rather than trying to trick the PB/DOS runtimes with asm
        techniques.

        Five of the maximum 20 default handles are reserved for system devices--
        stderr, stdout, stdin, stdaux, stdprn. To the extent you don't use
        these devices in your program, you can safely close them through asm
        calls, allowing their handles to be reused for your own purposes.
        This should be fully compatible with SHELL.

        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


        • #5
          Hello Lance, Michael & Tom
          Thanks for your comments and suggestions.
          I agree Shelling with files open may not be the best programming practice
          but I've been doing with a less than 15 files open in the past
          and had no problems. The suggestion to use DOS Int21h /67h came from
          PowerBasic support way back in the early nineties when I was using
          Version 2.X. It has worked well for me even with some programs where
          the open file count can rise as high as 33. I have never tried to
          open more than that but I undestand DOS allows up to 255 for a single
          process.
          My main concern is the fact that there is no problem with
          plain DOS 6.22 or Windows XP or 2000. Only W95/98/ME cause the GFP
          error. I am sure this is not PB/DOS problem. It was just an
          observation and thanks again for your comments and suggestions.

          Bernie




          ------------------
          [email protected]
          [email protected]

          Comment

          Working...
          X