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

Diff for /src/usr.bin/login/login.c between version 1.47 and 1.48

version 1.47, 2002/07/02 01:15:08 version 1.48, 2002/07/02 01:36:19
Line 100 
Line 100 
 #include <login_cap.h>  #include <login_cap.h>
 #include <netdb.h>  #include <netdb.h>
 #include <pwd.h>  #include <pwd.h>
 #include <setjmp.h>  
 #include <signal.h>  #include <signal.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdio.h>  #include <stdio.h>
Line 808 
Line 807 
         return ((t = getttynam(ttyn)) && t->ty_status & TTY_SECURE);          return ((t = getttynam(ttyn)) && t->ty_status & TTY_SECURE);
 }  }
   
 jmp_buf motdinterrupt;  
   
 void  void
 motd(void)  motd(void)
 {  {
         char tbuf[8192], *motd;          char tbuf[8192], *motd;
         int fd, nchars;          int fd, nchars;
         sig_t oldint;          struct sigaction sa, osa;
   
         motd = login_getcapstr(lc, "welcome", _PATH_MOTDFILE, _PATH_MOTDFILE);          motd = login_getcapstr(lc, "welcome", _PATH_MOTDFILE, _PATH_MOTDFILE);
   
         if ((fd = open(motd, O_RDONLY, 0)) < 0)          if ((fd = open(motd, O_RDONLY, 0)) < 0)
                 return;                  return;
         oldint = signal(SIGINT, sigint);  
         if (setjmp(motdinterrupt) == 0)          memset(&sa, 0, sizeof(sa));
                 while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0)          sa.sa_handler = sigint;
                         (void)write(fileno(stdout), tbuf, nchars);          sigemptyset(&sa.sa_mask);
         (void)signal(SIGINT, oldint);          sa.sa_flags = 0;                /* don't set SA_RESTART */
           (void)sigaction(SIGINT, &sa, &osa);
   
           /* read and spew motd until EOF, error, or SIGINT */
           while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0 &&
               write(STDOUT_FILENO, tbuf, nchars) == nchars)
                   ;
   
           (void)sigaction(SIGINT, &osa, NULL);
         (void)close(fd);          (void)close(fd);
 }  }
   
Line 833 
Line 838 
 void  void
 sigint(int signo)  sigint(int signo)
 {  {
         longjmp(motdinterrupt, 1);          return;                 /* just interupt syscall */
 }  }
   
 /* ARGSUSED */  /* ARGSUSED */

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.48