| * Mini getpty implementation for busybox |
| * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) |
| * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
| #if ENABLE_FEATURE_DEVPTS |
| p = open("/dev/ptmx", O_RDWR); |
| bb_perror_msg("ptsname error (is /dev/pts mounted?)"); |
| safe_strncpy(line, name, GETPTY_BUFSIZE); |
| strcpy(line, "/dev/ptyXX"); |
| for (i = 0; i < 16; i++) { |
| line[8] = "pqrstuvwxyzabcde"[i]; |
| if (stat(line, &stb) < 0) { |
| for (j = 0; j < 16; j++) { |
| line[9] = j < 10 ? j + '0' : j - 10 + 'a'; |
| fprintf(stderr, "Trying to open device: %s\n", line); |
| p = open(line, O_RDWR | O_NOCTTY); |
| #endif /* FEATURE_DEVPTS */ |
| USE_FEATURE_DEVPTS( fail:) |
| bb_error_msg_and_die("open pty"); |
| return -1; /* never get here */ |