version 1.36, 2017/07/08 22:07:39 |
version 1.37, 2017/07/08 22:14:48 |
|
|
void bye(int); |
void bye(int); |
void hi(int); |
void hi(int); |
|
|
struct timeval timeout; |
|
struct timeval zerotime; |
|
time_t nexttime; /* keep the timeout time */ |
|
int no_timeout; /* lock terminal forever */ |
int no_timeout; /* lock terminal forever */ |
|
|
extern char *__progname; |
extern char *__progname; |
|
|
char hostname[HOST_NAME_MAX+1], s[BUFSIZ], s1[BUFSIZ], date[256]; |
char hostname[HOST_NAME_MAX+1], s[BUFSIZ], s1[BUFSIZ], date[256]; |
char *p, *style, *nstyle, *ttynam; |
char *p, *style, *nstyle, *ttynam; |
struct itimerval ntimer, otimer; |
struct itimerval ntimer, otimer; |
|
struct timeval timeout; |
int ch, sectimeout, usemine, cnt, tries = 10, backoff = 3; |
int ch, sectimeout, usemine, cnt, tries = 10, backoff = 3; |
const char *errstr; |
const char *errstr; |
struct passwd *pw; |
struct passwd *pw; |
|
|
style = NULL; |
style = NULL; |
usemine = 0; |
usemine = 0; |
no_timeout = 0; |
no_timeout = 0; |
|
memset(&timeout, 0, sizeof(timeout)); |
|
|
if (pledge("stdio rpath wpath getpw tty proc exec", NULL) == -1) |
if (pledge("stdio rpath wpath getpw tty proc exec", NULL) == -1) |
err(1, "pledge"); |
err(1, "pledge"); |
|
|
if (!(ttynam = ttyname(STDIN_FILENO))) |
if (!(ttynam = ttyname(STDIN_FILENO))) |
errx(1, "not a terminal?"); |
errx(1, "not a terminal?"); |
curtime = time(NULL); |
curtime = time(NULL); |
nexttime = curtime + (sectimeout * 60); |
|
timp = localtime(&curtime); |
timp = localtime(&curtime); |
strftime(date, sizeof(date), "%c", timp); |
strftime(date, sizeof(date), "%c", timp); |
|
|
|
|
(void)signal(SIGTSTP, hi); |
(void)signal(SIGTSTP, hi); |
(void)signal(SIGALRM, bye); |
(void)signal(SIGALRM, bye); |
|
|
ntimer.it_interval = zerotime; |
memset(&ntimer, 0, sizeof(ntimer)); |
ntimer.it_value = timeout; |
ntimer.it_value = timeout; |
if (!no_timeout) |
if (!no_timeout) |
setitimer(ITIMER_REAL, &ntimer, &otimer); |
setitimer(ITIMER_REAL, &ntimer, &otimer); |