close/[1,2]
[ISO]close(
+Stream)
close(
+Stream,
+Options)
closes the stream corresponding to Stream.
Stream or file specification.
A list of zero or more of the following:
force(
Boolean)
true
), or not
(false
). The latter is the default. Currently this option has no
effect.
direction(
+Direction)
One of:
input
output
all
open/4
does nothing.
Closing a single direction is mainly useful when dealing with bidirectional streams, such as sockets.
If Stream is a stream object, then if the corresponding stream is open, it will be closed in the specified directions; otherwise, an error exception is raised.
If Stream is a file specification, the corresponding
stream will be closed in the specified directions,
provided that the file was opened by
see/1
or tell/1
.
Stream errors (see ref-iou-sfh-est), plus:
permission_error
see/1
or tell/1
.
domain_error
In this example, foo will be closed:
see(foo), ... close(foo)
However, in this example, a permission error will be raised and foo will not be closed:
open(foo, read, S), ... close(foo)
Here, close(S)
should have been used.
see/1
, tell/1
, open/[3,4]
,
ref-iou-sfh, lib-sockets.