diff --git a/src/apps/terminal/Shell.cpp b/src/apps/terminal/Shell.cpp index db6b3c2cee..4994584c93 100644 --- a/src/apps/terminal/Shell.cpp +++ b/src/apps/terminal/Shell.cpp @@ -337,11 +337,8 @@ initialize_termios(struct termios &tio) status_t Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **argv) { + const char* defaultArgs[3] = {kDefaultShell, "-l", NULL}; if (argv == NULL || argc == 0) { - const char *defaultArgs[2]; - defaultArgs[0] = kDefaultShell; - defaultArgs[1] = "-l"; - struct passwd passwdStruct; struct passwd *passwdResult; char stringBuffer[256]; @@ -356,58 +353,21 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg signal(SIGTTOU, SIG_IGN); -#ifdef __HAIKU__ // get a pseudo-tty int master = posix_openpt(O_RDWR | O_NOCTTY); const char *ttyName; -#else /* __HAIKU__ */ - /* - * Get a pseudo-tty. We do this by cycling through files in the - * directory. The operating system will not allow us to open a master - * which is already in use, so we simply go until the open succeeds. - */ - char ttyName[B_PATH_NAME_LENGTH]; - int master = -1; - DIR *dir = opendir("/dev/pt/"); - if (dir != NULL) { - struct dirent *dirEntry; - while ((dirEntry = readdir(dir)) != NULL) { - // skip '.' and '..' - if (dirEntry->d_name[0] == '.') - continue; - - char ptyName[B_PATH_NAME_LENGTH]; - snprintf(ptyName, sizeof(ptyName), "/dev/pt/%s", dirEntry->d_name); - - master = open(ptyName, O_RDWR); - if (master >= 0) { - // Set the tty that corresponds to the pty we found - snprintf(ttyName, sizeof(ttyName), "/dev/tt/%s", dirEntry->d_name); - break; - } else { - // B_BUSY is a normal case - if (errno != B_BUSY) - fprintf(stderr, B_TRANSLATE("could not open %s: %s\n"), - ptyName, strerror(errno)); - } - } - closedir(dir); - } -#endif /* __HAIKU__ */ if (master < 0) { fprintf(stderr, B_TRANSLATE("Didn't find any available pseudo ttys.")); return errno; } -#ifdef __HAIKU__ if (grantpt(master) != 0 || unlockpt(master) != 0 || (ttyName = ptsname(master)) == NULL) { close(master); fprintf(stderr, B_TRANSLATE("Failed to init pseudo tty.")); return errno; } -#endif /* __HAIKU__ */ /* * Get the modes of the current terminal. We will duplicates these @@ -515,9 +475,6 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg tcsetpgrp(0, getpgrp()); // set this process group ID as the controlling terminal -#ifndef __HAIKU__ - ioctl(0, 'pgid', getpid()); -#endif set_thread_priority(find_thread(NULL), B_NORMAL_PRIORITY); /* pty open and set termios successful. */