Skip to content

\UFSCloseFile will attempt to close an already closed file #1322

@nbriggs

Description

@nbriggs

There are two problems, fixing either of them will solve this -

  1. \UFSCloseFile tests for already-closed by whether or not the (UFSSTREAM UNIXNAME) field is NIL, but fails to set the UNIXNAME to NIL once the stream has been closed by the SUBR that does the OS related work.
  2. A more correct way to test for a closed stream is whether the (STREAM ACCESS) field is NIL, as done in \GETSTREAM

I propose changing the code to test for either (STREAM ACCESS) OR the UNIXNAME being NIL (implies already closed), and also setting the UNIXNAME to NIL after the file has been closed by the SUBR.

There's another minor design flaw - the underlying subr code doesn't distinguish between being passed NIL and 0 for the file descriptor - had it done that it would have been much more obvious that there was a problem, compared to the current behavior of just closing stdin (fd 0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions