aboutsummaryrefslogtreecommitdiff
path: root/jim-aio.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2015-03-19 15:30:40 +1000
committerSteve Bennett <steveb@workware.net.au>2015-03-19 19:45:24 +1000
commitc73f5c591b206c92f8021d01088738c908970d64 (patch)
treee7b46b13331151aabca095b1526664d6263941da /jim-aio.c
parentfffae89f567581b6138df5f20241f8851787fddd (diff)
downloadjimtcl-c73f5c591b206c92f8021d01088738c908970d64.zip
jimtcl-c73f5c591b206c92f8021d01088738c908970d64.tar.gz
jimtcl-c73f5c591b206c92f8021d01088738c908970d64.tar.bz2
aio: add 'sync' subcommand
If the underlying platform supports fsync(), $handle sync invokes fsync() on the stream file descriptor. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r--jim-aio.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/jim-aio.c b/jim-aio.c
index 9432c97..ef3f139 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -772,6 +772,17 @@ static int aio_cmd_ndelay(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
}
#endif
+#ifdef HAVE_FSYNC
+static int aio_cmd_sync(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+{
+ AioFile *af = Jim_CmdPrivData(interp);
+
+ fflush(af->fp);
+ fsync(af->fd);
+ return JIM_OK;
+}
+#endif
+
static int aio_cmd_buffering(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
@@ -995,6 +1006,15 @@ static const jim_subcmd_type aio_command_table[] = {
/* Description: Set O_NDELAY (if arg). Returns current/new setting. */
},
#endif
+#ifdef HAVE_FSYNC
+ { "sync",
+ NULL,
+ aio_cmd_sync,
+ 0,
+ 0,
+ /* Description: Flush and fsync() the stream */
+ },
+#endif
{ "buffering",
"none|line|full",
aio_cmd_buffering,