Code

sysdb: Handle EOF from the server.
[sysdb.git] / src / tools / sysdb / input.c
index f115e3e2a51088efdf2dec9e5547ffa1a60642cc..3814f0c2def7a239d8397d9cad4558cbd52112ae 100644 (file)
@@ -47,6 +47,7 @@
 #include "tools/sysdb/input.h"
 #include "tools/sysdb/command.h"
 
+#include "utils/error.h"
 #include "utils/strbuf.h"
 
 #include <sys/select.h>
@@ -178,6 +179,14 @@ input_readline(void)
                if (! FD_ISSET(client_fd, &fds))
                        continue;
 
+               if (sdb_client_eof(sysdb_input->client)) {
+                       /* XXX: try to reconnect */
+                       printf("\n");
+                       sdb_log(SDB_LOG_ERR, "Remote side closed the connection.");
+                       /* return EOF */
+                       return 0;
+               }
+
                /* some response / error message from the server pending */
                /* XXX: clear current line */
                printf("\n");