mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-23 04:14:18 +01:00
protocol: kill process group
This commit is contained in:
@@ -140,10 +140,12 @@ tty_client_destroy(struct tty_client *client) {
|
|||||||
pthread_cond_signal(&client->cond);
|
pthread_cond_signal(&client->cond);
|
||||||
pthread_mutex_unlock(&client->mutex);
|
pthread_mutex_unlock(&client->mutex);
|
||||||
|
|
||||||
// kill process and free resource
|
// kill process (group) and free resource
|
||||||
lwsl_notice("sending %s (%d) to process %d\n", server->sig_name, server->sig_code, client->pid);
|
int pgid = getpgid(client->pid);
|
||||||
if (kill(client->pid, server->sig_code) != 0) {
|
int pid = pgid > 0 ? -pgid : client->pid;
|
||||||
lwsl_err("kill: %d, errno: %d (%s)\n", client->pid, errno, strerror(errno));
|
lwsl_notice("sending %s (%d) to process (group) %d\n", server->sig_name, server->sig_code, pid);
|
||||||
|
if (kill(pid, server->sig_code) != 0) {
|
||||||
|
lwsl_err("kill: %d, errno: %d (%s)\n", pid, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
int status;
|
int status;
|
||||||
while (waitpid(client->pid, &status, 0) == -1 && errno == EINTR)
|
while (waitpid(client->pid, &status, 0) == -1 && errno == EINTR)
|
||||||
|
|||||||
Reference in New Issue
Block a user