abduco

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

commit a7e13911c568450e6a3c62d54c65a091fc441cc4
parent 3e4485642bd79f6a047c27bc494ad69918eedcd6
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue, 17 Jun 2014 23:36:47 +0200

Fix -n mode: do not wait for clients to connect

Diffstat:
abduco.c | 3+++
server.c | 5++++-
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/abduco.c b/abduco.c @@ -104,6 +104,7 @@ typedef struct { volatile sig_atomic_t running; const char *name; const char *session_name; + bool read_pty; } Server; static Server server = { .running = true, .exit_status = -1 }; @@ -465,6 +466,8 @@ int main(int argc, char *argv[]) { has_term = true; } + server.read_pty = (action == 'n'); + switch (action) { redo: case 'n': diff --git a/server.c b/server.c @@ -70,6 +70,7 @@ static Client *server_accept_client() { c->state = STATE_CONNECTED; c->next = server.clients; server.clients = c; + server.read_pty = true; return c; } @@ -151,6 +152,8 @@ static void server_mainloop() { FD_ZERO(&new_writefds); FD_SET(server.socket, &new_readfds); int new_fdmax = server.socket; + if (server.read_pty) + FD_SET_MAX(server.pty, &new_readfds, new_fdmax); Packet *exit_pkt = NULL; while (!exit_pkt) { @@ -243,7 +246,7 @@ static void server_mainloop() { c = c->next; } - if (server.running) + if (server.running && server.read_pty) FD_SET_MAX(server.pty, &new_readfds, new_fdmax); }