Changeset 25386

Show
Ignore:
Timestamp:
05/08/08 18:30:39 (7 months ago)
Author:
mmu_man
Message:

Sorry but I still need to test Terminal in BeOS to debug it... allstuff is #if(n)defed on HAIKU for clarity.
To be removed.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/apps/terminal/Shell.cpp

    r25166 r25386  
    284284        signal(SIGTTOU, SIG_IGN); 
    285285         
     286#ifdef __HAIKU__ 
    286287        // get a pseudo-tty 
    287288        int master = posix_openpt(O_RDWR | O_NOCTTY); 
    288289        const char *ttyName; 
     290#else /* __HAIKU__ */ 
     291        /* 
     292         * Get a pseudo-tty. We do this by cycling through files in the 
     293         * directory. The operating system will not allow us to open a master 
     294         * which is already in use, so we simply go until the open succeeds. 
     295         */ 
     296        char ttyName[B_PATH_NAME_LENGTH]; 
     297        int master = -1;         
     298        DIR *dir = opendir("/dev/pt/"); 
     299        if (dir != NULL) { 
     300                struct dirent *dirEntry; 
     301                while ((dirEntry = readdir(dir)) != NULL) {  
     302                        // skip '.' and '..' 
     303                        if (dirEntry->d_name[0] == '.') 
     304                                continue; 
     305 
     306                        char ptyName[B_PATH_NAME_LENGTH]; 
     307                        snprintf(ptyName, sizeof(ptyName), "/dev/pt/%s", dirEntry->d_name); 
     308 
     309                        master = open(ptyName, O_RDWR); 
     310                        if (master >= 0) { 
     311                                // Set the tty that corresponds to the pty we found 
     312                                snprintf(ttyName, sizeof(ttyName), "/dev/tt/%s", dirEntry->d_name); 
     313                                break; 
     314                        } else { 
     315                                // B_BUSY is a normal case 
     316                                if (errno != B_BUSY)  
     317                                        fprintf(stderr, "could not open %s: %s\n", ptyName, strerror(errno)); 
     318                        } 
     319                } 
     320                closedir(dir); 
     321        } 
     322#endif /* __HAIKU__ */ 
    289323 
    290324        if (master < 0) { 
     
    293327        } 
    294328 
     329#ifdef __HAIKU__ 
    295330        if (grantpt(master) != 0 || unlockpt(master) != 0 
    296331                || (ttyName = ptsname(master)) == NULL) { 
     
    299334                return errno; 
    300335        } 
     336#endif /* __HAIKU__ */ 
    301337 
    302338        /*