diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-03-01 17:29:48 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-03-01 17:29:48 +0300 |
commit | 79b578fe7dd93596de21cb70381e5aeeaa10ce67 (patch) | |
tree | a46f066e4ebc7ede653679def2ef894d03f2aece | |
parent | f68da4582f1976328db5564af544a8524fb30351 (diff) |
Fixes
-rw-r--r-- | clovershell.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/clovershell.c b/clovershell.c index b047343..5dd6304 100644 --- a/clovershell.c +++ b/clovershell.c @@ -167,10 +167,9 @@ void shell_data(int id, char* data, uint16_t len) if (write(c->fdm, data, len) < 0) { printf("fdm %d(%s) write error\n", id, c->fds); - close(c->fdm); - kill(c->reading_pid, SIGKILL); - free(shell_connections[id]); - shell_connections[id] = NULL; + if (c->shell_pid) kill(c->shell_pid, SIGKILL); + if (c->reading_pid) kill(c->reading_pid, SIGKILL); + exit(0); } } @@ -343,7 +342,14 @@ void exec_stdin(int id, char* data, uint16_t len) if (len > 0) { if (write(c->stdin[1], data, len) < 0) + { printf("exec %d write error\n", id); + if (c->exec_pid) kill(c->exec_pid, SIGKILL); + if (c->exec_result_pid) kill(c->exec_result_pid, SIGKILL); + if (c->stdout_pid) kill(c->stdout_pid, SIGKILL); + if (c->stderr_pid) kill(c->stderr_pid, SIGKILL); + exit(0); + } } else close(c->stdin[1]); } @@ -387,9 +393,9 @@ void cleanup() dead = 0; else c->shell_pid = 0; - //printf("Dead: %d\n", dead); if (dead) { + printf("cleaning %d shell connection\n", id); close(c->fdm); free(c); shell_connections[id] = NULL; @@ -415,9 +421,9 @@ void cleanup() dead = 0; else c->stderr_pid = 0; - //printf("Dead: %d\n", dead); if (dead) { + printf("cleaning %d exec connection\n", id); close(c->stdin[1]); free(c); exec_connections[id] = NULL; |