summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/MyPty.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/MyPty.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index 6d57703..315ea4a 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -40,96 +40,97 @@
40 40
41 \par FIXME 41 \par FIXME
42 42
43 [NOTE: much of the technical stuff below will be replaced by forkpty.] 43 [NOTE: much of the technical stuff below will be replaced by forkpty.]
44 44
45 publish the SIGCHLD signal if not related to an instance. 45 publish the SIGCHLD signal if not related to an instance.
46 46
47 clearify TEPty::done vs. TEPty::~TEPty semantics. 47 clearify TEPty::done vs. TEPty::~TEPty semantics.
48 check if pty is restartable via run after done. 48 check if pty is restartable via run after done.
49 49
50 \par Pseudo terminals 50 \par Pseudo terminals
51 51
52 Pseudo terminals are a unique feature of UNIX, and always come in form of 52 Pseudo terminals are a unique feature of UNIX, and always come in form of
53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each 53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
54 other by the operating system. One may think of them as two serial devices 54 other by the operating system. One may think of them as two serial devices
55 linked by a null-modem cable. Being based on devices the number of 55 linked by a null-modem cable. Being based on devices the number of
56 simultanous instances of this class is (globally) limited by the number of 56 simultanous instances of this class is (globally) limited by the number of
57 those device pairs, which is 256. 57 those device pairs, which is 256.
58 58
59 Another technic are UNIX 98 PTY's. These are supported also, and prefered 59 Another technic are UNIX 98 PTY's. These are supported also, and prefered
60 over the (obsolete) predecessor. 60 over the (obsolete) predecessor.
61 61
62 There's a sinister ioctl(2), signal(2) and job control stuff 62 There's a sinister ioctl(2), signal(2) and job control stuff
63 nessesary to make everything work as it should. 63 nessesary to make everything work as it should.
64*/ 64*/
65 65
66#include "procctl.h" 66#include "procctl.h"
67#include "MyPty.h" 67#include "MyPty.h"
68 68
69/* OPIE */ 69/* OPIE */
70#include <opie2/odebug.h> 70#include <opie2/odebug.h>
71using namespace Opie::Core; 71using namespace Opie::Core;
72 72
73/* QT */ 73/* QT */
74#include <qsocketnotifier.h> 74#include <qsocketnotifier.h>
75#include <qfile.h> 75#include <qfile.h>
76 76
77/* STD */ 77/* STD */
78#include <stdlib.h> 78#include <stdlib.h>
79#include <stdio.h> 79#include <stdio.h>
80#include <signal.h> 80#include <signal.h>
81#include <fcntl.h> 81#include <fcntl.h>
82#include <unistd.h> 82#include <unistd.h>
83#include <termios.h> 83#include <termios.h>
84#include <sys/types.h> 84#include <sys/types.h>
85#include <sys/ioctl.h> 85#include <sys/ioctl.h>
86#include <sys/wait.h> 86#include <sys/wait.h>
87 87
88
88#ifdef HAVE_OPENPTY 89#ifdef HAVE_OPENPTY
89#include <pty.h> 90#include <pty.h>
90#endif 91#endif
91 92
92#undef VERBOSE_DEBUG 93#undef VERBOSE_DEBUG
93 94
94 95
95/* -------------------------------------------------------------------------- */ 96/* -------------------------------------------------------------------------- */
96 97
97/*! 98/*!
98 Informs the client program about the 99 Informs the client program about the
99 actual size of the window. 100 actual size of the window.
100*/ 101*/
101 102
102void MyPty::setSize(int lines, int columns) 103void MyPty::setSize(int lines, int columns)
103{ 104{
104 owarn << "setting size" << oendl; 105 owarn << "setting size" << oendl;
105 struct winsize wsize; 106 struct winsize wsize;
106 wsize.ws_row = (unsigned short)lines; 107 wsize.ws_row = (unsigned short)lines;
107 wsize.ws_col = (unsigned short)columns; 108 wsize.ws_col = (unsigned short)columns;
108 if(m_fd < 0) return; 109 if(m_fd < 0) return;
109 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); 110 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
110} 111}
111 112
112 113
113void MyPty::donePty() 114void MyPty::donePty()
114{ 115{
115 // This is code from the Qt DumbTerminal example 116 // This is code from the Qt DumbTerminal example
116 117
117 ::close(m_fd); 118 ::close(m_fd);
118 119
119 if (m_cpid) { 120 if (m_cpid) {
120 kill(m_cpid, SIGHUP); 121 kill(m_cpid, SIGHUP);
121 //waitpid(m_cpid, &status, 0); 122 //waitpid(m_cpid, &status, 0);
122 delete m_sn_e; 123 delete m_sn_e;
123 delete m_sn_r; 124 delete m_sn_r;
124 m_sn_e = 0l; 125 m_sn_e = 0l;
125 m_sn_r = 0l; 126 m_sn_r = 0l;
126 } 127 }
127 128
128 m_cpid = 0; 129 m_cpid = 0;
129 m_fd = -1; 130 m_fd = -1;
130// emit done(status); 131// emit done(status);
131} 132}
132 133
133 134
134const char* MyPty::deviceName() 135const char* MyPty::deviceName()
135{ 136{