[BACK]Return to lock.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / lock

Diff for /src/usr.bin/lock/lock.c between version 1.36 and 1.37

version 1.36, 2017/07/08 22:07:39 version 1.37, 2017/07/08 22:14:48
Line 64 
Line 64 
 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;
Line 78 
Line 75 
         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;
Line 89 
Line 87 
         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");
Line 144 
Line 143 
         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);
   
Line 171 
Line 169 
         (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);

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37