Browse Source

klish: Exit on exit flag from net msg

Serj Kalichev 2 months ago
parent
commit
ce43cfa14f
2 changed files with 8 additions and 7 deletions
  1. 3 5
      bin/klish/interactive.c
  2. 5 2
      klish/ktp/ktp_session.c

+ 3 - 5
bin/klish/interactive.c

@@ -63,11 +63,8 @@ int klish_interactive_shell(ktp_session_t *ktp, struct options *opts)
 	faux_eloop_loop(eloop);
 
 	// Cleanup
-	if (tinyrl_busy(tinyrl)) {
+	if (tinyrl_busy(tinyrl))
 		faux_error_free(ktp_session_error(ktp));
-	} else {
-		tinyrl_multi_crlf(tinyrl);
-	}
 	tinyrl_free(tinyrl);
 
 	// Restore stdin mode
@@ -95,7 +92,8 @@ bool_t cmd_ack_cb(ktp_session_t *ktp, const faux_msg_t *msg, void *udata)
 	faux_error_free(error);
 
 	tinyrl_set_busy(ctx->tinyrl, BOOL_FALSE);
-	tinyrl_redisplay(ctx->tinyrl);
+	if (!ktp_session_done(ktp))
+		tinyrl_redisplay(ctx->tinyrl);
 
 	// Happy compiler
 	ktp = ktp;

+ 5 - 2
klish/ktp/ktp_session.c

@@ -337,7 +337,6 @@ static bool_t ktp_session_process_cmd_ack(ktp_session_t *ktp, const faux_msg_t *
 				ktp->cb[KTP_SESSION_CB_CMD_ACK_INCOMPLETED].fn)(
 				ktp, msg,
 				ktp->cb[KTP_SESSION_CB_CMD_ACK_INCOMPLETED].udata);
-printf("INCOMPLETED\n");
 		return BOOL_TRUE;
 	}
 
@@ -349,10 +348,14 @@ printf("INCOMPLETED\n");
 		faux_error_add(ktp->error, error_str);
 		faux_str_free(error_str);
 	}
-printf("COMPLETED %d %s\n", ktp->cmd_retcode, error_str);
+
 	ktp->cmd_retcode_available = BOOL_TRUE; // Answer from server was received
 	ktp->request_done = BOOL_TRUE;
 	ktp->state = KTP_SESSION_STATE_IDLE;
+	// Get exit flag from message
+	if (KTP_STATUS_IS_EXIT(faux_msg_get_status(msg)))
+		ktp->done = BOOL_TRUE;
+
 	// Execute external callback
 	if (ktp->cb[KTP_SESSION_CB_CMD_ACK].fn)
 		((ktp_session_event_cb_fn)