diff options
-rw-r--r-- | ChangeLog.txt | 3 | ||||
-rw-r--r-- | pseudo.c | 4 | ||||
-rw-r--r-- | pseudo_client.c | 17 | ||||
-rw-r--r-- | pseudo_client.h | 2 |
4 files changed, 17 insertions, 9 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index 411229f..e05572c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,6 @@ +2016-11-23: + * (seebs) actually wait on server shutdown for pseudo -S [cmd] + 2016-11-04: * (seebs) clarify usage message on missing --prefix @@ -334,7 +334,7 @@ main(int argc, char *argv[]) { /* If you didn't specify a command, opt_S shuts down here. */ if (opt_S && argc <= optind) { - return pseudo_client_shutdown(); + return pseudo_client_shutdown(0); } if (opt_d && opt_f) { @@ -409,7 +409,7 @@ main(int argc, char *argv[]) { * the server. */ if (opt_S) { - pseudo_client_shutdown(); + pseudo_client_shutdown(1); } if (WIFEXITED(rc)) { return WEXITSTATUS(rc); diff --git a/pseudo_client.c b/pseudo_client.c index b1a00fa..2a4c106 100644 --- a/pseudo_client.c +++ b/pseudo_client.c @@ -1357,7 +1357,7 @@ pseudo_client_request(pseudo_msg_t *msg, size_t len, const char *path) { } int -pseudo_client_shutdown(void) { +pseudo_client_shutdown(int wait_on_socket) { pseudo_msg_t msg; pseudo_msg_t *ack; char *pseudo_path; @@ -1428,12 +1428,17 @@ pseudo_client_shutdown(void) { pseudo_diag("server did not respond to shutdown query.\n"); return 1; } - if (ack->type == PSEUDO_MSG_ACK) { - return 0; + if (ack->type != PSEUDO_MSG_ACK) { + pseudo_diag("Server refused shutdown. Remaining client fds: %d\n", ack->fd); + pseudo_diag("Client pids: %s\n", ack->path); + pseudo_diag("Server will shut down after all clients exit.\n"); + } + if (wait_on_socket) { + /* try to receive a message the server won't send; + * this should abort/error-out when the server actually + * shuts down. */ + ack = pseudo_msg_receive(connect_fd); } - pseudo_diag("Server refused shutdown. Remaining client fds: %d\n", ack->fd); - pseudo_diag("Client pids: %s\n", ack->path); - pseudo_diag("Server will shut down after all clients exit.\n"); return 0; } diff --git a/pseudo_client.h b/pseudo_client.h index 68e5160..28b23dc 100644 --- a/pseudo_client.h +++ b/pseudo_client.h @@ -34,7 +34,7 @@ extern void pseudo_magic(void); extern void pseudo_client_touchuid(void); extern void pseudo_client_touchgid(void); extern char *pseudo_client_fdpath(int fd); -extern int pseudo_client_shutdown(void); +extern int pseudo_client_shutdown(int); extern int pseudo_fd(int fd, int how); #define MOVE_FD 0 #define COPY_FD 1 |