abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 54c1dbddb26ed060b3a6b841e8630c4e9f902b99
parent fdf943d520fc7c0e4d77f83a169941a76b14083e
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 18 Jun 2014 14:24:20 +0200

Mark zombie sessions with '+' symbol

These are sessions which have no clients connected but their underlying
command already terminated.

Diffstat:
abduco.c | 7++++++-
server.c | 12+++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/abduco.c b/abduco.c @@ -401,7 +401,12 @@ static int list_session() { struct stat sb; char buf[255]; if (stat(namelist[n]->d_name, &sb) == 0) { strftime(buf, sizeof(buf), "%a%t %F %T", localtime(&sb.st_atime)); - printf("%c %s\t%s\n", sb.st_mode & S_IXUSR ? '*' : ' ', buf, namelist[n]->d_name); + char status = ' '; + if (sb.st_mode & S_IXUSR) + status = '*'; + else if (sb.st_mode & S_IXGRP) + status = '+'; + printf("%c %s\t%s\n", status, buf, namelist[n]->d_name); } free(namelist[n]); } diff --git a/server.c b/server.c @@ -18,15 +18,16 @@ static void client_free(Client *c) { free(c); } -static int server_mark_socket_exec(bool exec) { +static int server_mark_socket_exec(bool exec, bool usr) { struct stat sb; if (stat(sockaddr.sun_path, &sb) == -1) return -1; mode_t mode = sb.st_mode; + mode_t flag = usr ? S_IXUSR : S_IXGRP; if (exec) - mode |= S_IXUSR; + mode |= flag; else - mode &= ~S_IXUSR; + mode &= ~flag; return chmod(sockaddr.sun_path, mode); } @@ -64,7 +65,7 @@ static Client *server_accept_client() { if (!c) return NULL; if (!server.clients) - server_mark_socket_exec(true); + server_mark_socket_exec(true, true); server_set_socket_non_blocking(newfd); c->socket = newfd; c->state = STATE_CONNECTED; @@ -122,6 +123,7 @@ static void server_pty_died_handler(int sig) { if (pid == -1) break; server.exit_status = WEXITSTATUS(server.exit_status); + server_mark_socket_exec(true, false); } debug("server pty died: %d\n", server.exit_status); @@ -196,7 +198,7 @@ static void server_mainloop() { }; server_send_packet(server.clients, &pkt); } else if (!server.clients) { - server_mark_socket_exec(false); + server_mark_socket_exec(false, true); } continue; }