diff options
author | Steve Bennett <steveb@workware.net.au> | 2015-03-19 15:30:40 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2015-03-19 19:45:24 +1000 |
commit | c73f5c591b206c92f8021d01088738c908970d64 (patch) | |
tree | e7b46b13331151aabca095b1526664d6263941da /jim-aio.c | |
parent | fffae89f567581b6138df5f20241f8851787fddd (diff) | |
download | jimtcl-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.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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, |