diff --git a/NEWS b/NEWS index ac4c3377..d2b66d5c 100644 --- a/NEWS +++ b/NEWS @@ -319,6 +319,7 @@ To be released as 0.11.4. hostname * bug 712: GnuTLS works on https://www-s.uiuc.edu/[] * fix active and passive FTP over IPv6 +* bug 938: elinks -remote no longer needs a controlling tty * bug 978: Python's webbrowser.open_new_tab(URL) works since now * minor bug 951 in user SMJS: garbage-collect SMJS objects on 'File -> Flush all caches' to work around their holding cache entries busy diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c index 1f2a6917..f37a9cfd 100644 --- a/src/terminal/kbd.c +++ b/src/terminal/kbd.c @@ -336,10 +336,12 @@ handle_trm(int std_in, int std_out, int sock_in, int sock_out, int ctl_in, #ifdef CONFIG_MOUSE enable_mouse(); #endif + handle_itrm_stdin(itrm); + } else { + /* elinks -remote may not have a valid stdin if not run from a tty (bug 938) */ + if (std_in >= 0) handle_itrm_stdin(itrm); } - handle_itrm_stdin(itrm); - if (sock_in != std_out) set_handlers(sock_in, (select_handler_T) in_sock, NULL, (select_handler_T) free_itrm, itrm); @@ -437,7 +439,8 @@ free_itrm(struct itrm *itrm) mem_free_set(&itrm->orig_title, NULL); - clear_handlers(itrm->in.std); + /* elinks -remote may not have a valid stdin if not run from a tty (bug 938) */ + if (!itrm->remote || itrm->in.std >= 0) clear_handlers(itrm->in.std); clear_handlers(itrm->in.sock); clear_handlers(itrm->out.std); clear_handlers(itrm->out.sock); @@ -1194,6 +1197,9 @@ in_kbd(struct itrm *itrm) static void handle_itrm_stdin(struct itrm *itrm) { + assert(itrm->in.std >= 0); + if_assert_failed return; + set_handlers(itrm->in.std, (select_handler_T) in_kbd, NULL, (select_handler_T) free_itrm, itrm); } @@ -1204,6 +1210,9 @@ handle_itrm_stdin(struct itrm *itrm) static void unhandle_itrm_stdin(struct itrm *itrm) { + assert(itrm->in.std >= 0); + if_assert_failed return; + set_handlers(itrm->in.std, (select_handler_T) NULL, NULL, (select_handler_T) free_itrm, itrm); }