libcli: Eliminate select from smb_readline_replacement
authorVolker Lendecke <vl@samba.org>
Mon, 14 Feb 2011 11:14:12 +0000 (12:14 +0100)
committerVolker Lendecke <vlendec@samba.org>
Mon, 28 Feb 2011 15:40:20 +0000 (16:40 +0100)
libcli/smbreadline/smbreadline.c

index f8441ac5a34956cdac20eaaa906812fbc0484edd..cff25a7f5a554c6af6620706d7a46dfdb5143a4e 100644 (file)
@@ -70,9 +70,7 @@ void smb_readline_done(void)
 static char *smb_readline_replacement(const char *prompt, void (*callback)(void),
                                char **(completion_fn)(const char *text, int start, int end))
 {
-       fd_set fds;
        char *line = NULL;
-       struct timeval timeout;
        int fd = x_fileno(x_stdin);
        char *ret;
 
@@ -88,13 +86,13 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void)
        }
 
        while (!smb_rl_done) {
-               timeout.tv_sec = 5;
-               timeout.tv_usec = 0;
+               struct pollfd pfd;
 
-               FD_ZERO(&fds);
-               FD_SET(fd,&fds);
+               ZERO_STRUCT(pfd);
+               pfd.fd = fd;
+               pfd.events = POLLIN|POLLHUP;
 
-               if (sys_select_intr(fd+1,&fds,NULL,NULL,&timeout) == 1) {
+               if (sys_poll_intr(&pfd, 1, 5000) == 1) {
                        ret = x_fgets(line, BUFSIZ, x_stdin);
                        if (ret == 0) {
                                SAFE_FREE(line);