From 4827854ac5e249ff7f91e9ae0d74f309b2195508 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 19 Jun 2023 09:23:52 +1000 Subject: aio: close should still close AIO_KEEPOPEN channels AIO_KEEPOPEN won't close a channel (such as stdin, stdout) when the command is deleted/replaced, but an explicit close will still close the channel. Signed-off-by: Steve Bennett --- jim-aio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'jim-aio.c') diff --git a/jim-aio.c b/jim-aio.c index 0e947db..abc7482 100644 --- a/jim-aio.c +++ b/jim-aio.c @@ -1368,12 +1368,12 @@ 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) { + AioFile *af = Jim_CmdPrivData(interp); if (argc == 3) { int option = -1; #if defined(HAVE_SOCKETS) static const char * const options[] = { "r", "w", "-nodelete", NULL }; enum { OPT_R, OPT_W, OPT_NODELETE }; - AioFile *af = Jim_CmdPrivData(interp); if (Jim_GetEnum(interp, argv[2], options, &option, NULL, JIM_ERRMSG) != JIM_OK) { return JIM_ERR; @@ -1403,6 +1403,9 @@ static int aio_cmd_close(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } } + /* Explicit close ignores AIO_KEEPOPEN */ + af->flags &= ~AIO_KEEPOPEN; + return Jim_DeleteCommand(interp, argv[0]); } -- cgit v1.1