- // open device
- sfd = open(argv[0], O_RDWR | O_NDELAY);
- if (sfd < 0) {
- bb_perror_msg("can't open device");
- goto unlock_and_exit;
- }
- fcntl(sfd, F_SETFL, O_RDWR); // why?
-
- // put stdin to "raw mode", handle one character at a time
- tcgetattr(STDIN_FILENO, &tio0);
- tio = tio0;
- tio.c_lflag &= ~(ICANON|ECHO);
- tio.c_iflag &= ~(IXON|ICRNL);
- tio.c_oflag &= ~(ONLCR);
- tio.c_cc[VMIN] = 1;
- tio.c_cc[VTIME] = 0;
- if (tcsetattr(STDIN_FILENO, TCSANOW, &tio)) {
- bb_perror_msg("can't tcsetattr for %s", "stdin");
- goto unlock_and_exit;
- }