2
* This file is a part of QTerminal - http://gitorious.org/qterminal
4
* This file was un-linked from KDE and modified
5
* by Maxim Bourmistrov <maxim@unixconn.com>
10
This file is part of the KDE libraries
12
Copyright (C) 2007 Oswald Buddenhagen <ossi@kde.org>
14
This library is free software; you can redistribute it and/or
15
modify it under the terms of the GNU Library General Public
16
License as published by the Free Software Foundation; either
17
version 2 of the License, or (at your option) any later version.
19
This library is distributed in the hope that it will be useful,
20
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
Library General Public License for more details.
24
You should have received a copy of the GNU Library General Public License
25
along with this library; see the file COPYING.LIB. If not, write to
26
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27
Boston, MA 02110-1301, USA.
31
#include "kptyprocess.h"
33
#include "kptydevice.h"
38
KPtyProcess::KPtyProcess(QObject *parent) :
39
KProcess(new KPtyProcessPrivate, parent)
43
d->pty = new KPtyDevice(this);
45
connect(this, SIGNAL(stateChanged(QProcess::ProcessState)),
46
SLOT(_k_onStateChanged(QProcess::ProcessState)));
49
KPtyProcess::KPtyProcess(int ptyMasterFd, QObject *parent) :
50
KProcess(new KPtyProcessPrivate, parent)
54
d->pty = new KPtyDevice(this);
55
d->pty->open(ptyMasterFd);
56
connect(this, SIGNAL(stateChanged(QProcess::ProcessState)),
57
SLOT(_k_onStateChanged(QProcess::ProcessState)));
60
KPtyProcess::~KPtyProcess()
64
if (state() != QProcess::NotRunning && d->addUtmp) {
66
disconnect(SIGNAL(stateChanged(QProcess::ProcessState)),
67
this, SLOT(_k_onStateChanged(QProcess::ProcessState)));
72
void KPtyProcess::setPtyChannels(PtyChannels channels)
76
d->ptyChannels = channels;
79
KPtyProcess::PtyChannels KPtyProcess::ptyChannels() const
81
Q_D(const KPtyProcess);
83
return d->ptyChannels;
86
void KPtyProcess::setUseUtmp(bool value)
93
bool KPtyProcess::isUseUtmp() const
95
Q_D(const KPtyProcess);
100
KPtyDevice *KPtyProcess::pty() const
102
Q_D(const KPtyProcess);
107
void KPtyProcess::setupChildProcess()
115
d->pty->login(KUser(KUser::UseRealUserID).loginName().toLocal8Bit().data(), qgetenv("DISPLAY"));
117
if (d->ptyChannels & StdinChannel)
118
dup2(d->pty->slaveFd(), 0);
120
if (d->ptyChannels & StdoutChannel)
121
dup2(d->pty->slaveFd(), 1);
123
if (d->ptyChannels & StderrChannel)
124
dup2(d->pty->slaveFd(), 2);
126
KProcess::setupChildProcess();
129
//#include "kptyprocess.moc"