diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2002-03-26 14:28:25 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2002-03-26 14:28:25 +0000 |
commit | fc5d8b43441885afd78465b390584a9483ddbc3c (patch) | |
tree | 95ee29c8ebfad77a411aaa45c8a868c168674641 | |
parent | ae91006786152b13191685993b95e9050d01c956 (diff) |
ne pas lever d'exception si on flushe un channel ferme
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4563 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | byterun/io.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/byterun/io.c b/byterun/io.c index f473ce7d2..85f162aa2 100644 --- a/byterun/io.c +++ b/byterun/io.c @@ -172,12 +172,19 @@ again: /* Attempt to flush the buffer. This will make room in the buffer for at least one character. Returns true if the buffer is empty at the - end of the flush, or false if some data remains in the buffer. */ + end of the flush, or false if some data remains in the buffer. + + If the channel is closed, DO NOT raise a "bad file descriptor" + exception, but do nothing (the buffer is already empty). See + the "at_exit" line of stdlib/format.ml for a good reason to avoid + the exception. + */ CAMLexport int flush_partial(struct channel *channel) { int towrite, written; + if (channel->fd == -1) return 1; towrite = channel->curr - channel->buff; if (towrite > 0) { written = do_write(channel->fd, channel->buff, towrite); |