Browse Source

Merge branch 'master' of https://src.libcode.org/pkun/klish

Serj Kalichev 1 year ago
parent
commit
b4facd94ec
3 changed files with 7 additions and 2 deletions
  1. 3 0
      bin/klish/klish.c
  2. 0 1
      bin/klishd/klishd.c
  3. 4 1
      klish/ktp/ktpd_session.c

+ 3 - 0
bin/klish/klish.c

@@ -99,6 +99,9 @@ int main(int argc, char **argv)
 	ktp_session_set_cb(ktp, KTP_SESSION_CB_STDOUT, stdout_cb, NULL);
 	ktp_session_set_cb(ktp, KTP_SESSION_CB_STDERR, stderr_cb, NULL);
 
+	// Ignore SIGPIPE from server
+	signal(SIGPIPE, SIG_IGN);
+
 	// Commands from cmdline
 	if (faux_list_len(opts->commands) > 0) {
 		const char *line = NULL;

+ 0 - 1
bin/klishd/klishd.c

@@ -200,7 +200,6 @@ err: // For listen daemon
 	// Create KTP session
 	// Function ktpd_session_new() will add new events to eloop itself.
 	ktpd_session = ktpd_session_new(client_fd, scheme, NULL, eloop);
-	assert(ktpd_session);
 	if (!ktpd_session) {
 		syslog(LOG_ERR, "Can't create KTPd session\n");
 		goto err_client;

+ 4 - 1
klish/ktp/ktpd_session.c

@@ -82,7 +82,10 @@ ktpd_session_t *ktpd_session_new(int sock, kscheme_t *scheme,
 	ktpd->state = KTPD_SESSION_STATE_IDLE;
 	ktpd->eloop = eloop;
 	ktpd->session = ksession_new(scheme, start_entry);
-	assert(ktpd->session);
+	if (!ktpd->session) {
+		faux_free(ktpd);
+		return NULL;
+	}
 	ktpd->exec = NULL;
 	// Exit flag. It differs from ksession done flag because KTPD session
 	// can't exit immediately. It must finish current command processing