1 /* vi: set sw=4 ts=4: */
3 * Mini getpty implementation for busybox
4 * Bjorn Wesen, Axis Communications AB (bjornw@axis.com)
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
15 int getpty(char *line)
18 #if ENABLE_FEATURE_DEVPTS
19 p = open("/dev/ptmx", O_RDWR);
26 bb_perror_msg("ptsname error (is /dev/pts mounted?)");
29 safe_strncpy(line, name, GETPTY_BUFSIZE);
37 strcpy(line, "/dev/ptyXX");
39 for (i = 0; i < 16; i++) {
40 line[8] = "pqrstuvwxyzabcde"[i];
42 if (stat(line, &stb) < 0) {
45 for (j = 0; j < 16; j++) {
46 line[9] = j < 10 ? j + '0' : j - 10 + 'a';
48 fprintf(stderr, "Trying to open device: %s\n", line);
49 p = open(line, O_RDWR | O_NOCTTY);
56 #endif /* FEATURE_DEVPTS */