aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auto.def1
-rw-r--r--jim-aio.c26
-rw-r--r--jim_tcl.txt8
3 files changed, 29 insertions, 6 deletions
diff --git a/auto.def b/auto.def
index 556361a..59baea0 100644
--- a/auto.def
+++ b/auto.def
@@ -87,6 +87,7 @@ cc-check-functions ualarm lstat fork vfork system select execvpe
cc-check-functions backtrace geteuid mkstemp realpath strptime isatty
cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
+cc-check-functions shutdown
if {[cc-check-functions sysinfo]} {
cc-with {-includes sys/sysinfo.h} {
cc-check-members "struct sysinfo.uptime"
diff --git a/jim-aio.c b/jim-aio.c
index fc80307..4ccdae4 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -667,6 +667,26 @@ static int aio_cmd_eof(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int aio_cmd_close(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
+ if (argc == 3) {
+#ifdef HAVE_SHUTDOWN
+ static const char * const options[] = { "r", "w", NULL };
+ enum { OPT_R, OPT_W, };
+ int option;
+ AioFile *af = Jim_CmdPrivData(interp);
+
+ if (Jim_GetEnum(interp, argv[2], options, &option, NULL, JIM_ERRMSG) != JIM_OK) {
+ return JIM_ERR;
+ }
+ if (shutdown(af->fd, option == OPT_R ? SHUT_RD : SHUT_WR) == 0) {
+ return JIM_OK;
+ }
+ JimAioSetError(interp, NULL);
+#else
+ Jim_SetResultString(interp, "async close not supported", -1);
+#endif
+ return JIM_ERR;
+ }
+
return Jim_DeleteCommand(interp, Jim_String(argv[0]));
}
@@ -926,12 +946,12 @@ static const jim_subcmd_type aio_command_table[] = {
/* Description: Returns 1 if stream is at eof */
},
{ "close",
- NULL,
+ "?r(ead)|w(rite)?",
aio_cmd_close,
0,
- 0,
+ 1,
JIM_MODFLAG_FULLARGV,
- /* Description: Closes the stream */
+ /* Description: Closes the stream. */
},
{ "seek",
"offset ?start|current|end",
diff --git a/jim_tcl.txt b/jim_tcl.txt
index 85d5046..80e7673 100644
--- a/jim_tcl.txt
+++ b/jim_tcl.txt
@@ -56,7 +56,8 @@ Changes between 0.74 and 0.75
1. `binary`, `pack` and `unpack` now support floating point
2. `file copy` '-force' handles source and target as the same file
3. `format` now supports +%b+ for binary conversion
-3. `lsort` now supports '-unique' and '-real'
+4. `lsort` now supports '-unique' and '-real'
+5. Add support for half-close with `aio close` ?r|w?
Changes between 0.73 and 0.74
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -4426,8 +4427,9 @@ aio
+$handle *buffering none|line|full*+::
Sets the buffering mode of the stream.
-+$handle *close*+::
- Closes the stream
++$handle *close* ?r(ead)|w(rite)?+::
+ Closes the stream.
+ The two-argument form is a "half-close" on a socket. See the +shutdown(2)+ man page.
+$handle *copyto* 'tofd ?size?'+::
Copy bytes to the file descriptor +'tofd'+. If +'size'+ is specified, at most