12.9.3 Interacting with foreign streams
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • Foreign access to Prolog IO streams
          • Interacting with foreign streams
            • Sset_timeout()
            • Sunit_size()
            • Sputc()
            • Sgetc()
            • Sfgetc()
            • Sungetc()
            • Sputcode()
            • Sgetcode()
            • Speekcode()
            • Sputw()
            • Sgetw()
            • Sfread()
            • Sfwrite()
            • Sfeof()
            • Sfpasteof()
            • Ssetlocale()
            • Sflush()
            • Ssize()
            • Sseek()
            • Sseek64()
            • Stell()
            • Stell64()
            • Sclose()
            • Sgcclose()
            • Sfgets()
            • Sgets()
            • Sread_pending()
            • Spending()
            • Sfputs()
            • Sputs()
            • Sfprintf()
            • Sprintf()
            • Svprintf()
            • Ssprintf()
            • Ssnprintf()
            • Svsprintf()
            • Svsnprintf()
            • Sdprintf()
            • Svdprintf()
            • Slock()
            • StryLock()
            • Sunlock()
            • Sfileno()
            • Swinsock()
            • Sclosehook()
            • Sset_filter()
            • Ssetbuffer()
    • Packages
Availability:C-language interface function
int Sgcclose(IOSTREAM *s, int flags)
As Sclose(), but intended to be used from the atom garbage collector if a stream is closed because it is garbage. The SWI-Prolog atom garbage collector normally runs in a separate thread and thus may be unable to obtain a lock on s if some thread lost access to the stream while it is locked. For this situation flags may be SIO_CLOSE_TRYLOCK which causes Sgcclose() to return -1 with errno set to EDEADLK if the stream is locked. Alternatively, using SIO_CLOSE_FORCE the stream is closed and released without gaining a lock. This should be safe because the stream is garbage and thus no thread can use the lock.

In addition, Sgcclose() never raises a Prolog exception because Prolog interaction is not allowed from the blob release hook and there is no meaningful way to raise a Prolog exception from this context.