diff --git a/src/telnet_basic.c b/src/telnet_basic.c index f3c64ee..37b3ad4 100644 --- a/src/telnet_basic.c +++ b/src/telnet_basic.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "telnet.h" #include "telnet_param.h" @@ -284,12 +285,12 @@ int telnet_open(tn_ctx_t *tcc, int mode) while (1) { res = tcc->srv_rx(tcc->cctx, 1000); - if (res <= 0) - return -1; + if (res < 0) + return errno; else if (tcc->mode_rfc2217) return 0; - else if (t - time(NULL) > 2) - return -1; + else if (time(NULL) - t > 10) + return EPROTO; } } diff --git a/src/ttynvt.c b/src/ttynvt.c index 468f762..32229bf 100644 --- a/src/ttynvt.c +++ b/src/ttynvt.c @@ -470,9 +470,9 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info) res = telnet_open(tty->tn, ttynvt_param.raw ? TN_MODE_RAW : TN_MODE_TELNET); - if (res < 0) + if (res != 0) { - errno = EPROTO; + errno = res; goto open_err; }