commit - c2e630e5159aca0f69626f8315c68ae951323e79
commit + 85b8fe265cb79cbf965a09c9a87f49fde1fde424
blob - 1081ab94e94d21c43eddc424f5fd22ce4d9964c0
blob + 28a21b307bb4f32e1d414fe6942373cb17223981
--- lstun.1
+++ lstun.1
.It Fl t Ar timeout
Number of seconds after after the last client shutdown to kill the ssh
process.
+Set to zero to keep the tunnel open indefinitely.
Defaults to 120.
.El
.Sh AUTHORS
blob - 5279ad62d3c4799899b8920e312200b86081abb3
blob + 0b1e1a19d512093453cea57dea1758bc0fa5b2f0
--- lstun.c
+++ lstun.c
struct event sigchldev;
struct event siginfoev;
-struct timeval timeout;
+struct timeval timeout = {120, 0};
struct event timeoutev;
pid_t ssh_pid = -1;
if (--conn == 0) {
warnx("scheduling ssh termination (%llds)",
(long long)timeout.tv_sec);
- evtimer_set(&timeoutev, killing_time, NULL);
- evtimer_add(&timeoutev, &timeout);
+ if (timeout.tv_sec != 0) {
+ evtimer_set(&timeoutev, killing_time, NULL);
+ evtimer_add(&timeoutev, &timeout);
+ }
}
}
int
main(int argc, char **argv)
{
- int ch, i, tout = 0;
+ int ch, i;
const char *errstr;
while ((ch = getopt(argc, argv, "B:b:t:")) != -1) {
addr = optarg;
break;
case 't':
- tout = strtonum(optarg, 1, INT_MAX, &errstr);
+ timeout.tv_sec = strtonum(optarg, 0, INT_MAX, &errstr);
if (errstr != NULL)
errx(1, "timeout is %s: %s", errstr, optarg);
break;
if (argc != 1 || addr == NULL || ssh_tflag == NULL)
usage();
- if (tout == 0)
- tout = 120;
-
- timeout.tv_sec = tout;
- timeout.tv_usec = 0;
-
ssh_dest = argv[0];
for (i = 0; i < MAXCONN; ++i) {