- 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()
- SfprintfX()
- Sprintf()
- Svprintf()
- Ssprintf()
- Ssnprintf()
- SsnprintfX()
- Svsprintf()
- Svsnprintf()
- Sdprintf()
- SdprintfX()
- Svdprintf()
- Slock()
- StryLock()
- Sunlock()
- Sfileno()
- Swinsock()
- Sclosehook()
- Sset_filter()
- Ssetbuffer()
- Running a child process on a Windows terminal
- Writing Prolog terms to foreign streams
- Interacting with foreign streams
- Foreign access to Prolog IO streams
- Foreign Language Interface
- Packages
- Reference manual
12.9.3.1 Running a child process on a Windows terminal
A child process gets a terminal on Windows by attaching to a pseudo console. The Epilog window (see swipl-win.exe) has no console of its own: it talks to its Prolog thread over two pipes, and a child handed those has nothing that echoes what it reads, no window size and no way to be interrupted. The functions below put such a child on the console of the terminal behind a stream. This is what shell/1 does, and what process_create/3 does for the streams the caller left alone. They exist on Windows only.
- HANDLE Swinpseudoconsole(IOSTREAM *s)
- Claim the pseudo console of the terminal behind s, or
NULLif it has none to give. This is a claim rather than a query: the console reads and writes the same pipe ends as the stream, so the terminal runs one only while a client holds it, and the holder must touch neither the stream nor its companions meanwhile. DeclaredHANDLEbecauseHPCONpostdatesSWI-Stream.h; they are the same. - void Swinrelease_pseudoconsole(IOSTREAM *s)
- Hand the console back once the child is gone. The terminal closes it when the last client has released it.
- void * Swinpseudoconsole_attributes(HANDLE hpcon)
- Process attribute list that puts a child on hpcon, or
NULLif it cannot be built. Pass it as thelpAttributeListof aSTARTUPINFOEXWand create the process withEXTENDED_STARTUPINFO_PRESENT. Not withCREATE_NO_WINDOW: that asks for a console of the child's own, which is the opposite of what the attribute says and wins. - void Swinfree_pseudoconsole_attributes(void *attributes)
- Free the list once the child is created. The console itself is held until Swinrelease_pseudoconsole().