diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-27 00:23:57 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-27 00:23:57 +0200 |
commit | fd1549ce42f891f7f78e95a0797235cc100d3823 (patch) | |
tree | 97191921407080d88e7e786ecba2d35783d9ffa9 /module/util | |
parent | Crash properly on overflow on remove event. (diff) | |
download | calp-fd1549ce42f891f7f78e95a0797235cc100d3823.tar.gz calp-fd1549ce42f891f7f78e95a0797235cc100d3823.tar.xz |
Cleanup in atomic-output...
Diffstat (limited to '')
-rw-r--r-- | module/util/io.scm | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/module/util/io.scm b/module/util/io.scm index 1652f042..50f01e12 100644 --- a/module/util/io.scm +++ b/module/util/io.scm @@ -38,18 +38,20 @@ (lambda () (set! port (mkstemp! tmpfile))) (lambda () (with-output-to-port port thunk) - ;; (force-output port) - ;; TODO check buffereing, might throw exception? + ;; Closing a port forces a write, due to buffering + ;; some of the errors that logically would come + ;; from write calls are first raised here. But since + ;; crashing is acceptable here, that's fine. (close-port port) (rename-file tmpfile filename)) (lambda () - ;; (force-output port) - ;; TODO check buffereing, might throw exception? - ;; tmpfile still existing means that we never hit the - ;; rename above, clean up the file and note that we failed. (when (access? tmpfile F_OK) - (close-port port) + ;; I'm a bit unclear on how to trash our write buffer. + ;; hopefully first removing the file, followed by closing + ;; the port is enough for the kernel to do the sensible + ;; thing. (delete-file tmpfile) + (close-port port) ;; `when' defaults to the truthy `()', see (util) ;; (note that #<unspecified> is thruthy, but shouldn't be ;; counted on, since anything with an unspecified return |