2 This file is part of the KDE libraries
4 Copyright (C) 2007 Oswald Buddenhagen <ossi@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
23 #include "kptyprocess.h"
24 #include "kprocess_p.h"
27 #include <kptydevice.h>
36 struct KPtyProcessPrivate
: KProcessPrivate
{
37 KPtyProcessPrivate() :
38 ptyChannels(KPtyProcess::NoChannels
),
44 KPtyProcess::PtyChannels ptyChannels
;
48 KPtyProcess::KPtyProcess(QObject
*parent
) :
49 KProcess(new KPtyProcessPrivate
, parent
)
53 d
->pty
= new KPtyDevice(this);
57 KPtyProcess::KPtyProcess(int ptyMasterFd
, QObject
*parent
) :
58 KProcess(new KPtyProcessPrivate
, parent
)
62 d
->pty
= new KPtyDevice(this);
63 d
->pty
->open(ptyMasterFd
);
66 KPtyProcess::~KPtyProcess()
73 void KPtyProcess::setPtyChannels(PtyChannels channels
)
77 d
->ptyChannels
= channels
;
80 KPtyProcess::PtyChannels
KPtyProcess::ptyChannels() const
82 Q_D(const KPtyProcess
);
84 return d
->ptyChannels
;
87 void KPtyProcess::setUseUtmp(bool value
)
94 bool KPtyProcess::isUseUtmp() const
96 Q_D(const KPtyProcess
);
101 KPtyDevice
*KPtyProcess::pty() const
103 Q_D(const KPtyProcess
);
108 void KPtyProcess::setupChildProcess()
114 d
->pty
->login(KUser(KUser::UseRealUserID
).loginName().toLocal8Bit().data(), qgetenv("DISPLAY"));
115 if (d
->ptyChannels
& StdinChannel
)
116 dup2(d
->pty
->slaveFd(), 0);
117 if (d
->ptyChannels
& StdoutChannel
)
118 dup2(d
->pty
->slaveFd(), 1);
119 if (d
->ptyChannels
& StderrChannel
)
120 dup2(d
->pty
->slaveFd(), 2);
122 KProcess::setupChildProcess();
125 #include "kptyprocess.moc"