This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problems with tcgetattr()


Hi,

I am in the process of writing a simple authentication module for the administration of our card. For this we need to be able to hide the password when it is inputed. From what I can tell using tcgetattr() and tcsetattr() are the calls that I need. The problem is that when I try using tcgetattr() I get the error:

   tcgetattr: Invalid argument

I am not sure what's going on or how to resolve the issue. Any ideas?
(I have attached the C/C++ source).

Andre

void LoginShell::GetPass( string & str)
{
      struct termios term;
      struct termios termsave;
      string text;
                
      /* make sure this is a tty */
      if (!isatty(STDIN_FILENO)) {
        fprintf(stderr,"isatty: STDIN_FILENO not a tty\n");
        exit(1);
      }
    
      /* get term i/o flags for this tty */      
      if (tcgetattr(STDIN_FILENO, &termsave) < 0) {
        perror("tcgetattr");
        exit(1);
      }
    
      term = termsave;                  /* termsave contains old termios */
      term.c_lflag &= ~ECHO;            /* turn off echo if it's set */
    
      /* propagate changes */
      if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &term) < 0) {
        perror("tcsetattr");
        exit(1);
      }
    
      cin >> text;
      str.append(text);
                
      /* restore old state */
      if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &termsave) < 0) {
        perror("tcsetattr");
       exit(1);
      } 
}



-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]