Diffstat (limited to 'core/apps/embeddedkonsole/MyPty.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/MyPty.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/apps/embeddedkonsole/MyPty.cpp b/core/apps/embeddedkonsole/MyPty.cpp index 9adc248..7e820ad 100644 --- a/core/apps/embeddedkonsole/MyPty.cpp +++ b/core/apps/embeddedkonsole/MyPty.cpp | |||
@@ -150,33 +150,34 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int) | |||
150 | dup2(ttyfd, STDIN_FILENO); | 150 | dup2(ttyfd, STDIN_FILENO); |
151 | dup2(ttyfd, STDOUT_FILENO); | 151 | dup2(ttyfd, STDOUT_FILENO); |
152 | dup2(ttyfd, STDERR_FILENO); | 152 | dup2(ttyfd, STDERR_FILENO); |
153 | // should be done with tty, so close it | 153 | // should be done with tty, so close it |
154 | close(ttyfd); | 154 | close(ttyfd); |
155 | static struct termios ttmode; | 155 | static struct termios ttmode; |
156 | if ( setsid() < 0 ) | 156 | if ( setsid() < 0 ) |
157 | perror( "failed to set process group" ); | 157 | perror( "failed to set process group" ); |
158 | #if defined (TIOCSCTTY) | 158 | #if defined (TIOCSCTTY) |
159 | // grabbed from APUE by Stevens | 159 | // grabbed from APUE by Stevens |
160 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 160 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
161 | #endif | 161 | #endif |
162 | tcgetattr( STDIN_FILENO, &ttmode ); | 162 | tcgetattr( STDIN_FILENO, &ttmode ); |
163 | ttmode.c_cc[VINTR] = 3; | 163 | ttmode.c_cc[VINTR] = 3; |
164 | ttmode.c_cc[VERASE] = 8; | 164 | ttmode.c_cc[VERASE] = 8; |
165 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 165 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
166 | setenv("TERM","vt100",1); | 166 | if(strlen(getenv("TERM"))<=0) |
167 | setenv("TERM","vt100",1); | ||
167 | setenv("COLORTERM","0",1); | 168 | setenv("COLORTERM","0",1); |
168 | 169 | ||
169 | if (getuid() == 0) { | 170 | if (getuid() == 0) { |
170 | char msg[] = "WARNING: You are running this shell as root!\n"; | 171 | char msg[] = "WARNING: You are running this shell as root!\n"; |
171 | write(ttyfd, msg, sizeof(msg)); | 172 | write(ttyfd, msg, sizeof(msg)); |
172 | } | 173 | } |
173 | 174 | ||
174 | QString ccmd = "-"+QFileInfo(cmd).fileName(); //creates a login shell | 175 | QString ccmd = "-"+QFileInfo(cmd).fileName(); //creates a login shell |
175 | 176 | ||
176 | execl(cmd, ccmd.latin1(), 0); | 177 | execl(cmd, ccmd.latin1(), 0); |
177 | 178 | ||
178 | donePty(); | 179 | donePty(); |
179 | exit(-1); | 180 | exit(-1); |
180 | } | 181 | } |
181 | 182 | ||
182 | // parent - continue as a widget | 183 | // parent - continue as a widget |