summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-15 01:14:17 (UTC)
committer zecke <zecke>2002-10-15 01:14:17 (UTC)
commite0efd37513192d9a17fa9a9f46bbaed0ca38029c (patch) (side-by-side diff)
tree04163d93fc4c4185d322912e9430eff9b36b71cc
parentb12b38a00c66ddc100f3fff75478539b8b797928 (diff)
downloadopie-e0efd37513192d9a17fa9a9f46bbaed0ca38029c.zip
opie-e0efd37513192d9a17fa9a9f46bbaed0ca38029c.tar.gz
opie-e0efd37513192d9a17fa9a9f46bbaed0ca38029c.tar.bz2
The right way to deal with the pipe
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp10
-rw-r--r--noncore/apps/opie-console/MyPty.h2
2 files changed, 9 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index cacb4ce..ae01392 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -107,25 +107,27 @@ void MyPty::setSize(int lines, int columns)
void MyPty::donePty()
{
// This is code from the Qt DumbTerminal example
int status = 0;
::close(m_fd);
if (m_cpid) {
qWarning("killing!!!");
kill(m_cpid, SIGHUP);
- waitpid(m_cpid, &status, 0);
+ //waitpid(m_cpid, &status, 0);
+ delete m_sn_e;
+ m_sn_e = 0l;
}
m_cpid = 0;
// emit done(status);
}
const char* MyPty::deviceName()
{
return m_ttynam;
}
@@ -177,27 +179,28 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int)
if (getuid() == 0) {
char msg[] = "WARNING: You are running this shell as root!\n";
write(ttyfd, msg, sizeof(msg));
}
execl(cmd, cmd, 0);
donePty();
exit(-1);
}
// parent - continue as a widget
QSocketNotifier* sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this);
-// QSocketNotifier* sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this);
+ delete m_sn_e;
+ m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this);
connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
-// connect(sn_e,SIGNAL(activated(int)),this,SLOT(error()));
+ connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error()));
return 0;
}
int MyPty::openPty()
{
// This is code from the Qt DumbTerminal example
int ptyfd = -1;
#ifdef HAVE_OPENPTY
int ttyfd;
if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) )
@@ -223,24 +226,25 @@ int MyPty::openPty()
qApp->exit(1);
return -1;
}
return ptyfd;
}
/*!
Create an instance.
*/
MyPty::MyPty(const Profile&) : m_cpid(0)
{
+ m_sn_e = 0l;
m_fd = openPty();
ProcCtl* ctl = ProcCtl::self();
}
/*!
Destructor.
Note that the related client program is not killed
(yet) when a instance is deleted.
*/
MyPty::~MyPty()
{
donePty();
diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h
index 9231a8a..3166fa0 100644
--- a/noncore/apps/opie-console/MyPty.h
+++ b/noncore/apps/opie-console/MyPty.h
@@ -19,24 +19,25 @@
/*! \file
*/
#ifndef MY_PTY_H
#define MY_PTY_H
#include <qobject.h>
#include <qstrlist.h>
#include "io_layer.h"
class Profile;
+class QSocketNotifier;
class MyPty : public IOLayer
{
Q_OBJECT
public:
MyPty(const Profile&);
~MyPty();
QString identifier()const;
QString name()const;
@@ -81,15 +82,16 @@ protected slots:
void readPty();
void donePty();
private:
int openPty();
private:
char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx"
char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..."
int m_fd;
int m_cpid;
+ QSocketNotifier* m_sn_e;
};
#endif