From 26411b5359fd5b362623889ee54951f72a15c3f7 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 17 Aug 2010 15:02:10 +0000 Subject: [PATCH] * Remove legacy BeOS code * Ensure the argument list passed to execve is NULL-terminated * Also declare it earlier to make sure gcc4 doesn't erase it from memory when getting out of the if block. This *should* fix gcc4 Terminal, and *does not* break it under gcc2. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38189 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/Shell.cpp | 45 +------------------------------------ 1 file changed, 1 insertion(+), 44 deletions(-) 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. */