Diffstat (limited to 'noncore/apps/opie-console/MyPty.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 6b0d6f2..16bb5ff 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -166,25 +166,25 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int) | |||
166 | ::close(ttyfd); | 166 | ::close(ttyfd); |
167 | static struct termios ttmode; | 167 | static struct termios ttmode; |
168 | if ( setsid() < 0 ) | 168 | if ( setsid() < 0 ) |
169 | perror( "failed to set process group" ); | 169 | perror( "failed to set process group" ); |
170 | #if defined (TIOCSCTTY) | 170 | #if defined (TIOCSCTTY) |
171 | // grabbed from APUE by Stevens | 171 | // grabbed from APUE by Stevens |
172 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 172 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
173 | #endif | 173 | #endif |
174 | tcgetattr( STDIN_FILENO, &ttmode ); | 174 | tcgetattr( STDIN_FILENO, &ttmode ); |
175 | ttmode.c_cc[VINTR] = 3; | 175 | ttmode.c_cc[VINTR] = 3; |
176 | ttmode.c_cc[VERASE] = 8; | 176 | ttmode.c_cc[VERASE] = 8; |
177 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 177 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
178 | setenv("TERM","vt100",1); | 178 | setenv("TERM",m_term,1); |
179 | setenv("COLORTERM","0",1); | 179 | setenv("COLORTERM","0",1); |
180 | 180 | ||
181 | if (getuid() == 0) { | 181 | if (getuid() == 0) { |
182 | char msg[] = "WARNING: You are running this shell as root!\n"; | 182 | char msg[] = "WARNING: You are running this shell as root!\n"; |
183 | write(ttyfd, msg, sizeof(msg)); | 183 | write(ttyfd, msg, sizeof(msg)); |
184 | } | 184 | } |
185 | execl(cmd, cmd, 0); | 185 | execl(cmd, cmd, 0); |
186 | 186 | ||
187 | donePty(); | 187 | donePty(); |
188 | exit(-1); | 188 | exit(-1); |
189 | } | 189 | } |
190 | 190 | ||
@@ -227,26 +227,41 @@ int MyPty::openPty() | |||
227 | 227 | ||
228 | if ( ptyfd < 0 ) { | 228 | if ( ptyfd < 0 ) { |
229 | //qApp->exit(1); | 229 | //qApp->exit(1); |
230 | return -1; | 230 | return -1; |
231 | } | 231 | } |
232 | 232 | ||
233 | return ptyfd; | 233 | return ptyfd; |
234 | } | 234 | } |
235 | 235 | ||
236 | /*! | 236 | /*! |
237 | Create an instance. | 237 | Create an instance. |
238 | */ | 238 | */ |
239 | MyPty::MyPty(const Profile&) : m_cpid(0) | 239 | MyPty::MyPty(const Profile& prof) : m_cpid(0) |
240 | { | 240 | { |
241 | |||
242 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); | ||
243 | switch( term ) { | ||
244 | default: | ||
245 | case Profile::VT100: | ||
246 | case Profile::VT102: | ||
247 | m_term = "vt100"; | ||
248 | break; | ||
249 | case Profile::Linux: | ||
250 | m_term = "linux"; | ||
251 | break; | ||
252 | case Profile::XTerm: | ||
253 | m_term = "xterm"; | ||
254 | break; | ||
255 | } | ||
241 | m_sn_e = 0l; | 256 | m_sn_e = 0l; |
242 | m_sn_r = 0l; | 257 | m_sn_r = 0l; |
243 | m_fd = openPty(); | 258 | m_fd = openPty(); |
244 | ProcCtl* ctl = ProcCtl::self(); | 259 | ProcCtl* ctl = ProcCtl::self(); |
245 | } | 260 | } |
246 | 261 | ||
247 | /*! | 262 | /*! |
248 | Destructor. | 263 | Destructor. |
249 | Note that the related client program is not killed | 264 | Note that the related client program is not killed |
250 | (yet) when a instance is deleted. | 265 | (yet) when a instance is deleted. |
251 | */ | 266 | */ |
252 | MyPty::~MyPty() | 267 | MyPty::~MyPty() |