summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index 2570826..534f79a 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -100,97 +100,97 @@
100void MyPty::setSize(int lines, int columns) 100void MyPty::setSize(int lines, int columns)
101{ 101{
102 qWarning("setting size"); 102 qWarning("setting size");
103 struct winsize wsize; 103 struct winsize wsize;
104 wsize.ws_row = (unsigned short)lines; 104 wsize.ws_row = (unsigned short)lines;
105 wsize.ws_col = (unsigned short)columns; 105 wsize.ws_col = (unsigned short)columns;
106 if(m_fd < 0) return; 106 if(m_fd < 0) return;
107 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); 107 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
108} 108}
109 109
110 110
111void MyPty::donePty() 111void MyPty::donePty()
112{ 112{
113 // This is code from the Qt DumbTerminal example 113 // This is code from the Qt DumbTerminal example
114 114
115 ::close(m_fd); 115 ::close(m_fd);
116 116
117 if (m_cpid) { 117 if (m_cpid) {
118 kill(m_cpid, SIGHUP); 118 kill(m_cpid, SIGHUP);
119 //waitpid(m_cpid, &status, 0); 119 //waitpid(m_cpid, &status, 0);
120 delete m_sn_e; 120 delete m_sn_e;
121 delete m_sn_r; 121 delete m_sn_r;
122 m_sn_e = 0l; 122 m_sn_e = 0l;
123 m_sn_r = 0l; 123 m_sn_r = 0l;
124 } 124 }
125 125
126 m_cpid = 0; 126 m_cpid = 0;
127 m_fd = -1; 127 m_fd = -1;
128// emit done(status); 128// emit done(status);
129} 129}
130 130
131 131
132const char* MyPty::deviceName() 132const char* MyPty::deviceName()
133{ 133{
134 return m_ttynam; 134 return m_ttynam;
135} 135}
136 136
137 137
138void MyPty::error() 138void MyPty::error()
139{ 139{
140 // This is code from the Qt DumbTerminal example 140 // This is code from the Qt DumbTerminal example
141 donePty(); 141 donePty();
142} 142}
143 143
144void MyPty::start() { 144void MyPty::start() {
145 char* cmd = "/bin/sh"; 145 char* cmd = "/bin/sh";
146 146
147 if ( QFile::exists( "/bin/bash" ) ) { 147 if ( QFile::exists( "/bin/bash" ) ) {
148 char* cmd = "/bin/bash"; 148 cmd = "/bin/bash";
149 } 149 }
150 150
151 QStrList lis; 151 QStrList lis;
152 int r =run(cmd, lis, 0, 0); 152 int r =run(cmd, lis, 0, 0);
153 r = r; 153 r = r;
154} 154}
155/*! 155/*!
156 start the client program. 156 start the client program.
157*/ 157*/
158int MyPty::run(const char* cmd, QStrList &, const char*, int) 158int MyPty::run(const char* cmd, QStrList &, const char*, int)
159{ 159{
160 // This is code from the Qt DumbTerminal example 160 // This is code from the Qt DumbTerminal example
161 m_cpid = fork(); 161 m_cpid = fork();
162 162
163 if ( !m_cpid ) { 163 if ( !m_cpid ) {
164 // child - exec shell on tty 164 // child - exec shell on tty
165 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); 165 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
166 int ttyfd = ::open(m_ttynam, O_RDWR); 166 int ttyfd = ::open(m_ttynam, O_RDWR);
167 dup2(ttyfd, STDIN_FILENO); 167 dup2(ttyfd, STDIN_FILENO);
168 dup2(ttyfd, STDOUT_FILENO); 168 dup2(ttyfd, STDOUT_FILENO);
169 dup2(ttyfd, STDERR_FILENO); 169 dup2(ttyfd, STDERR_FILENO);
170 // should be done with tty, so close it 170 // should be done with tty, so close it
171 ::close(ttyfd); 171 ::close(ttyfd);
172 static struct termios ttmode; 172 static struct termios ttmode;
173 if ( setsid() < 0 ) 173 if ( setsid() < 0 )
174 perror( "failed to set process group" ); 174 perror( "failed to set process group" );
175#if defined (TIOCSCTTY) 175#if defined (TIOCSCTTY)
176 // grabbed from APUE by Stevens 176 // grabbed from APUE by Stevens
177 ioctl(STDIN_FILENO, TIOCSCTTY, 0); 177 ioctl(STDIN_FILENO, TIOCSCTTY, 0);
178#endif 178#endif
179 tcgetattr( STDIN_FILENO, &ttmode ); 179 tcgetattr( STDIN_FILENO, &ttmode );
180 ttmode.c_cc[VINTR] = 3; 180 ttmode.c_cc[VINTR] = 3;
181 ttmode.c_cc[VERASE] = 8; 181 ttmode.c_cc[VERASE] = 8;
182 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); 182 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
183 setenv("TERM",m_term,1); 183 setenv("TERM",m_term,1);
184 setenv("COLORTERM","0",1); 184 setenv("COLORTERM","0",1);
185 185
186 if (getuid() == 0) { 186 if (getuid() == 0) {
187 char msg[] = "WARNING: You are running this shell as root!\n"; 187 char msg[] = "WARNING: You are running this shell as root!\n";
188 write(ttyfd, msg, sizeof(msg)); 188 write(ttyfd, msg, sizeof(msg));
189 } 189 }
190 execl(cmd, cmd, 0); 190 execl(cmd, cmd, 0);
191 191
192 donePty(); 192 donePty();
193 exit(-1); 193 exit(-1);
194 } 194 }
195 195
196 // parent - continue as a widget 196 // parent - continue as a widget