| 1 | /* |
| 2 | * This file is a part of QTerminal - http://gitorious.org/qterminal |
| 3 | * |
| 4 | * This file was un-linked from KDE and modified |
| 5 | * by Maxim Bourmistrov <[email protected]> |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | This file is part of the KDE libraries |
| 11 | |
| 12 | Copyright (C) 2007 Oswald Buddenhagen <[email protected]> |
| 13 | |
| 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. |
| 18 | |
| 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. |
| 23 | |
| 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. |
| 28 | */ |
| 29 | |
| 30 | #include "kprocess.h"cxx . . $ `<file>/lib/kprocess.h`/ |
| 31 | |
| 32 | #include <qfile.h> |
| 33 | |
| 34 | #ifdef Q_OS_WIN |
| 35 | # include <windows.h> |
| 36 | #else |
| 37 | # include <unistd.h> |
| 38 | # include <cerrno> |
| 39 | #endif |
| 40 | |
| 41 | #ifndef Q_OS_WIN |
| 42 | # define STD_OUTPUT_HANDLEcxx . . $ `lib/kprocess.cpp:42:10`! 1 |
| 43 | # define STD_ERROR_HANDLEcxx . . $ `lib/kprocess.cpp:43:10`! 2 |
| 44 | #endif |
| 45 | |
| 46 | #ifdef _WIN32_WCE |
| 47 | #include <stdio.h> |
| 48 | #endif |
| 49 | |
| 50 | void KProcessPrivatecxx . . $ KProcessPrivate#::writeAllcxx . . $ KProcessPrivate#writeAll(e825830302b8bb52).(const QByteArraycxx . . $ QByteArray# &buf, int fd) |
| 51 | { |
| 52 | #ifdef Q_OS_WIN |
| 53 | #ifndef _WIN32_WCE |
| 54 | HANDLE h = GetStdHandle(fd); |
| 55 | if (h) { |
| 56 | DWORD wr; |
| 57 | WriteFile(h, buf.data(), buf.size(), &wr, 0); |
| 58 | } |
| 59 | #else |
| 60 | fwrite(buf.data(), 1, buf.size(), (FILE*)fd); |
| 61 | #endif |
| 62 | #else |
| 63 | int off = 0; |
| 64 | do { |
| 65 | int ret = ::write(fd, buf.datacxx . . $ QByteArray#data(a9f41ea0e82d88cf).() + off, buf.sizecxx . . $ QByteArray#size(455f465bc33b4cdf).() - off); |
| 66 | if (ret < 0) { |
| 67 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`!) |
| 68 | return; |
| 69 | } else { |
| 70 | off += ret; |
| 71 | } |
| 72 | } while (off < buf.sizecxx . . $ QByteArray#size(455f465bc33b4cdf).()); |
| 73 | #endif |
| 74 | } |
| 75 | |
| 76 | void KProcessPrivatecxx . . $ KProcessPrivate#::forwardStdcxx . . $ KProcessPrivate#forwardStd(142b2ac9de4808e5).(KProcesscxx . . $ KProcess#::ProcessChannelcxx . . $ QProcess#ProcessChannel# good, int fd) |
| 77 | { |
| 78 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(KProcess); |
| 79 | |
| 80 | QProcesscxx . . $ QProcess#::ProcessChannelcxx . . $ QProcess#ProcessChannel# oc = q->readChannelcxx . . $ QProcess#readChannel(5873b69d383d719c).(); |
| 81 | q->setReadChannelcxx . . $ QProcess#setReadChannel(bf19820e89ffcdec).(good); |
| 82 | writeAllcxx . . $ KProcessPrivate#writeAll(e825830302b8bb52).(q->readAllcxx . . $ QIODevice#readAll(b3c286cec66e09f4).(), fd); |
| 83 | q->setReadChannelcxx . . $ QProcess#setReadChannel(bf19820e89ffcdec).(oc); |
| 84 | } |
| 85 | |
| 86 | void KProcessPrivatecxx . . $ KProcessPrivate#::_k_forwardStdoutcxx . . $ KProcessPrivate#_k_forwardStdout(49f6e7a06ebc5aa8).() |
| 87 | { |
| 88 | #ifndef _WIN32_WCE |
| 89 | forwardStdcxx . . $ KProcessPrivate#forwardStd(142b2ac9de4808e5).(KProcesscxx . . $ KProcess#::StandardOutputcxx . . $ QProcess#StandardOutput., STD_OUTPUT_HANDLEcxx . . $ `lib/kprocess.cpp:42:10`!); |
| 90 | #else |
| 91 | forwardStd(KProcess::StandardOutput, (int)stdout); |
| 92 | #endif |
| 93 | } |
| 94 | |
| 95 | void KProcessPrivatecxx . . $ KProcessPrivate#::_k_forwardStderrcxx . . $ KProcessPrivate#_k_forwardStderr(49f6e7a06ebc5aa8).() |
| 96 | { |
| 97 | #ifndef _WIN32_WCE |
| 98 | forwardStdcxx . . $ KProcessPrivate#forwardStd(142b2ac9de4808e5).(KProcesscxx . . $ KProcess#::StandardErrorcxx . . $ QProcess#StandardError., STD_ERROR_HANDLEcxx . . $ `lib/kprocess.cpp:43:10`!); |
| 99 | #else |
| 100 | forwardStd(KProcess::StandardError, (int)stderr); |
| 101 | #endif |
| 102 | } |
| 103 | |
| 104 | ///////////////////////////// |
| 105 | // public member functions // |
| 106 | ///////////////////////////// |
| 107 | |
| 108 | KProcesscxx . . $ KProcess#::KProcesscxx . . $ KProcess#KProcess(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) : |
| 109 | QProcesscxx . . $ QProcess#(parent), |
| 110 | d_ptrcxx . . $ KProcess#d_ptr.(new KProcessPrivatecxx . . $ KProcessPrivate#KProcessPrivate(49f6e7a06ebc5aa8).) |
| 111 | { |
| 112 | d_ptrcxx . . $ KProcess#d_ptr.->q_ptrcxx . . $ KProcessPrivate#q_ptr. = this; |
| 113 | setOutputChannelModecxx . . $ KProcess#setOutputChannelMode(4e12b81a1edb9757).(ForwardedChannelscxx . . $ KProcess#ForwardedChannels.); |
| 114 | } |
| 115 | |
| 116 | KProcesscxx . . $ KProcess#::KProcesscxx . . $ KProcess#KProcess(b033d96fac6e7eff).(KProcessPrivatecxx . . $ KProcessPrivate# *d, QObjectcxx . . $ QObject# *parent) : |
| 117 | QProcesscxx . . $ QProcess#(parent), |
| 118 | d_ptrcxx . . $ KProcess#d_ptr.(d) |
| 119 | { |
| 120 | d_ptrcxx . . $ KProcess#d_ptr.->q_ptrcxx . . $ KProcessPrivate#q_ptr. = this; |
| 121 | setOutputChannelModecxx . . $ KProcess#setOutputChannelMode(4e12b81a1edb9757).(ForwardedChannelscxx . . $ KProcess#ForwardedChannels.); |
| 122 | } |
| 123 | |
| 124 | KProcesscxx . . $ KProcess#::~cxx . . $ KProcess#`~KProcess`(ced63f7c635d850d).KProcesscxx . . $ KProcess#() |
| 125 | { |
| 126 | delete d_ptrcxx . . $ KProcess#d_ptr.; |
| 127 | } |
| 128 | |
| 129 | void KProcesscxx . . $ KProcess#::setOutputChannelModecxx . . $ KProcess#setOutputChannelMode(4e12b81a1edb9757).(OutputChannelModecxx . . $ KProcess#OutputChannelMode# mode) |
| 130 | { |
| 131 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 132 | |
| 133 | d->outputChannelModecxx . . $ KProcessPrivate#outputChannelMode. = mode; |
| 134 | disconnectcxx . . $ QObject#disconnect(105bbb4f746c4352).(this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(readyReadStandardOutput())); |
| 135 | disconnectcxx . . $ QObject#disconnect(105bbb4f746c4352).(this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(readyReadStandardError())); |
| 136 | switch (mode) { |
| 137 | case OnlyStdoutChannelcxx . . $ KProcess#OnlyStdoutChannel.: |
| 138 | connectcxx . . $ QObject#connect(f4332061c7e4ca89).(this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(readyReadStandardError()), SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(_k_forwardStderr())); |
| 139 | break; |
| 140 | case OnlyStderrChannelcxx . . $ KProcess#OnlyStderrChannel.: |
| 141 | connectcxx . . $ QObject#connect(f4332061c7e4ca89).(this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(readyReadStandardOutput()), SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(_k_forwardStdout())); |
| 142 | break; |
| 143 | default: |
| 144 | QProcesscxx . . $ QProcess#::setProcessChannelModecxx . . $ QProcess#setProcessChannelMode(325e95cd0c77e646).((ProcessChannelModecxx . . $ QProcess#ProcessChannelMode#)mode); |
| 145 | return; |
| 146 | } |
| 147 | QProcesscxx . . $ QProcess#::setProcessChannelModecxx . . $ QProcess#setProcessChannelMode(325e95cd0c77e646).(QProcesscxx . . $ QProcess#::SeparateChannelscxx . . $ QProcess#SeparateChannels.); |
| 148 | } |
| 149 | |
| 150 | KProcesscxx . . $ KProcess#::OutputChannelModecxx . . $ KProcess#OutputChannelMode# KProcesscxx . . $ KProcess#::outputChannelModecxx . . $ KProcess#outputChannelMode(f5f7a7c4a35b9602).() const |
| 151 | { |
| 152 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const KProcess); |
| 153 | |
| 154 | return d->outputChannelModecxx . . $ KProcessPrivate#outputChannelMode.; |
| 155 | } |
| 156 | |
| 157 | void KProcesscxx . . $ KProcess#::setNextOpenModecxx . . $ KProcess#setNextOpenMode(6a9e152534c2b05f).(QIODevicecxx . . $ QIODevice#::OpenModecxx . . $ QIODevice#OpenMode# mode) |
| 158 | { |
| 159 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 160 | |
| 161 | d->openModecxx . . $ KProcessPrivate#openMode. =cxx . . $ QFlags#`operator=`(a67466f4f57919fb). mode; |
| 162 | } |
| 163 | |
| 164 | #define DUMMYENVcxx . . $ `lib/kprocess.cpp:164:9`! "_KPROCESS_DUMMY_=" |
| 165 | |
| 166 | void KProcesscxx . . $ KProcess#::clearEnvironmentcxx . . $ KProcess#clearEnvironment(49f6e7a06ebc5aa8).() |
| 167 | { |
| 168 | setEnvironmentcxx . . $ QProcess#setEnvironment(631c0101495f0328).(QStringListcxx . . $ QStringList#QStringList(ced63f7c635d850d).() <<cxx . . $ QStringList#`operator<<`(85116071a693d053). QStringcxx . . $ QString#::fromLatin1cxx . . $ QString#fromLatin1(5ac70cc0fa2a874e).(DUMMYENVcxx . . $ `lib/kprocess.cpp:164:9`!)); |
| 169 | } |
| 170 | |
| 171 | void KProcesscxx . . $ KProcess#::setEnvcxx . . $ KProcess#setEnv(79b500c10be86587).(const QStringcxx . . $ QString# &name, const QStringcxx . . $ QString# &value, bool overwrite) |
| 172 | { |
| 173 | QStringListcxx . . $ QStringList# env = environmentcxx . . $ QProcess#environment(e1dbd5c4feadc8f5).(); |
| 174 | if (env.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) { |
| 175 | env =cxx . . $ QStringList#`operator=`(335bb966c1744308). systemEnvironmentcxx . . $ QProcess#systemEnvironment(669a05bc42dd57cc).(); |
| 176 | env.removeAllcxx . . $ QList#removeAll(dd8e59d271e40448).(QStringcxx . . $ QString#::fromLatin1cxx . . $ QString#fromLatin1(5ac70cc0fa2a874e).(DUMMYENVcxx . . $ `lib/kprocess.cpp:164:9`!)); |
| 177 | } |
| 178 | QStringcxx . . $ QString# fnamecxx . . $ QString#QString(132dd6869045752b).(name); |
| 179 | fname.appendcxx . . $ QString#append(3a2ffbdf8ecc25e2).(QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('=')); |
| 180 | for (QStringListcxx . . $ QStringList#::Iteratorcxx . . $ QList#Iterator# it = env.begincxx . . $ QList#begin(ca2520f641887418).(); it !=cxx . . $ QList#iterator#`operator!=`(afde28160b321935). env.endcxx . . $ QList#end(ca2520f641887418).(); ++cxx . . $ QList#iterator#operator++(c343742bd746e713).it) |
| 181 | if ((*cxx . . $ QList#iterator#`operator*`(c93303b41ac66b6d).it).startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).(fname)) { |
| 182 | if (overwrite) { |
| 183 | *cxx . . $ QList#iterator#`operator*`(c93303b41ac66b6d).it =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). fname.appendcxx . . $ QString#append(6a89d0b7f4d2681c).(value); |
| 184 | setEnvironmentcxx . . $ QProcess#setEnvironment(631c0101495f0328).(env); |
| 185 | } |
| 186 | return; |
| 187 | } |
| 188 | env.appendcxx . . $ QList#append(77d9f17553126ecb).(fname.appendcxx . . $ QString#append(6a89d0b7f4d2681c).(value)); |
| 189 | setEnvironmentcxx . . $ QProcess#setEnvironment(631c0101495f0328).(env); |
| 190 | } |
| 191 | |
| 192 | void KProcesscxx . . $ KProcess#::unsetEnvcxx . . $ KProcess#unsetEnv(3520e46b33348bf6).(const QStringcxx . . $ QString# &name) |
| 193 | { |
| 194 | QStringListcxx . . $ QStringList# env = environmentcxx . . $ QProcess#environment(e1dbd5c4feadc8f5).(); |
| 195 | if (env.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) { |
| 196 | env =cxx . . $ QStringList#`operator=`(335bb966c1744308). systemEnvironmentcxx . . $ QProcess#systemEnvironment(669a05bc42dd57cc).(); |
| 197 | env.removeAllcxx . . $ QList#removeAll(dd8e59d271e40448).(QStringcxx . . $ QString#::fromLatin1cxx . . $ QString#fromLatin1(5ac70cc0fa2a874e).(DUMMYENVcxx . . $ `lib/kprocess.cpp:164:9`!)); |
| 198 | } |
| 199 | QStringcxx . . $ QString# fnamecxx . . $ QString#QString(132dd6869045752b).(name); |
| 200 | fname.appendcxx . . $ QString#append(3a2ffbdf8ecc25e2).(QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('=')); |
| 201 | for (QStringListcxx . . $ QStringList#::Iteratorcxx . . $ QList#Iterator# it = env.begincxx . . $ QList#begin(ca2520f641887418).(); it !=cxx . . $ QList#iterator#`operator!=`(afde28160b321935). env.endcxx . . $ QList#end(ca2520f641887418).(); ++cxx . . $ QList#iterator#operator++(c343742bd746e713).it) |
| 202 | if ((*cxx . . $ QList#iterator#`operator*`(c93303b41ac66b6d).it).startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).(fname)) { |
| 203 | env.erasecxx . . $ QList#erase(71808fbec92a204b).(itcxx . . $ QList#iterator#iterator(e54296d6df58d214).); |
| 204 | if (env.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) |
| 205 | env.appendcxx . . $ QList#append(77d9f17553126ecb).(QStringcxx . . $ QString#::fromLatin1cxx . . $ QString#fromLatin1(5ac70cc0fa2a874e).(DUMMYENVcxx . . $ `lib/kprocess.cpp:164:9`!)); |
| 206 | setEnvironmentcxx . . $ QProcess#setEnvironment(631c0101495f0328).(env); |
| 207 | return; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | void KProcesscxx . . $ KProcess#::setProgramcxx . . $ KProcess#setProgram(4a8467afe4f213e4).(const QStringcxx . . $ QString# &exe, const QStringListcxx . . $ QStringList# &args) |
| 212 | { |
| 213 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 214 | |
| 215 | d->progcxx . . $ KProcessPrivate#prog. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). exe; |
| 216 | d->argscxx . . $ KProcessPrivate#args. =cxx . . $ QStringList#`operator=`(cb3c3d1614140851). args; |
| 217 | #ifdef Q_OS_WIN |
| 218 | setNativeArguments(QString()); |
| 219 | #endif |
| 220 | } |
| 221 | |
| 222 | void KProcesscxx . . $ KProcess#::setProgramcxx . . $ KProcess#setProgram(631c0101495f0328).(const QStringListcxx . . $ QStringList# &argv) |
| 223 | { |
| 224 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 225 | |
| 226 | Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!( !argv.isEmpty() ); |
| 227 | d->argscxx . . $ KProcessPrivate#args. =cxx . . $ QStringList#`operator=`(cb3c3d1614140851). argv; |
| 228 | d->progcxx . . $ KProcessPrivate#prog. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). d->argscxx . . $ KProcessPrivate#args..takeFirstcxx . . $ QList#takeFirst(5f357b03ed472e5e).(); |
| 229 | #ifdef Q_OS_WIN |
| 230 | setNativeArguments(QString()); |
| 231 | #endif |
| 232 | } |
| 233 | |
| 234 | KProcesscxx . . $ KProcess# &KProcesscxx . . $ KProcess#::operatorcxx . . $ KProcess#`operator<<`(2c634c354ea22620).<<(const QStringcxx . . $ QString# &arg) |
| 235 | { |
| 236 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 237 | |
| 238 | if (d->progcxx . . $ KProcessPrivate#prog..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 239 | d->progcxx . . $ KProcessPrivate#prog. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). arg; |
| 240 | else |
| 241 | d->argscxx . . $ KProcessPrivate#args. <<cxx . . $ QStringList#`operator<<`(85116071a693d053). arg; |
| 242 | return *this; |
| 243 | } |
| 244 | |
| 245 | KProcesscxx . . $ KProcess# &KProcesscxx . . $ KProcess#::operatorcxx . . $ KProcess#`operator<<`(24186fe4219131c9).<<(const QStringListcxx . . $ QStringList# &args) |
| 246 | { |
| 247 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 248 | |
| 249 | if (d->progcxx . . $ KProcessPrivate#prog..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 250 | setProgramcxx . . $ KProcess#setProgram(631c0101495f0328).(args); |
| 251 | else |
| 252 | d->argscxx . . $ KProcessPrivate#args. <<cxx . . $ QStringList#`operator<<`(cb3c3d1614140851). args; |
| 253 | return *this; |
| 254 | } |
| 255 | |
| 256 | void KProcesscxx . . $ KProcess#::clearProgramcxx . . $ KProcess#clearProgram(49f6e7a06ebc5aa8).() |
| 257 | { |
| 258 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 259 | |
| 260 | d->progcxx . . $ KProcessPrivate#prog..clearcxx . . $ QString#clear(49f6e7a06ebc5aa8).(); |
| 261 | d->argscxx . . $ KProcessPrivate#args..clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 262 | #ifdef Q_OS_WIN |
| 263 | setNativeArguments(QString()); |
| 264 | #endif |
| 265 | } |
| 266 | |
| 267 | #if 0 |
| 268 | void KProcess::setShellCommand(const QString &cmd) |
| 269 | { |
| 270 | Q_D(KProcess); |
| 271 | |
| 272 | KShell::Errors err; |
| 273 | d->args = KShell::splitArgs( |
| 274 | cmd, KShell::AbortOnMeta | KShell::TildeExpand, &err); |
| 275 | if (err == KShell::NoError && !d->args.isEmpty()) { |
| 276 | d->prog = KStandardDirs::findExe(d->args[0]); |
| 277 | if (!d->prog.isEmpty()) { |
| 278 | d->args.removeFirst(); |
| 279 | #ifdef Q_OS_WIN |
| 280 | setNativeArguments(QString()); |
| 281 | #endif |
| 282 | return; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | d->args.clear(); |
| 287 | |
| 288 | #ifdef Q_OS_UNIX |
| 289 | // #ifdef NON_FREE // ... as they ship non-POSIX /bin/sh |
| 290 | # if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__GNU__) |
| 291 | // If /bin/sh is a symlink, we can be pretty sure that it points to a |
| 292 | // POSIX shell - the original bourne shell is about the only non-POSIX |
| 293 | // shell still in use and it is always installed natively as /bin/sh. |
| 294 | d->prog = QFile::symLinkTarget(QString::fromLatin1("/bin/sh")); |
| 295 | if (d->prog.isEmpty()) { |
| 296 | // Try some known POSIX shells. |
| 297 | d->prog = KStandardDirs::findExe(QString::fromLatin1("ksh")); |
| 298 | if (d->prog.isEmpty()) { |
| 299 | d->prog = KStandardDirs::findExe(QString::fromLatin1("ash")); |
| 300 | if (d->prog.isEmpty()) { |
| 301 | d->prog = KStandardDirs::findExe(QString::fromLatin1("bash")); |
| 302 | if (d->prog.isEmpty()) { |
| 303 | d->prog = KStandardDirs::findExe(QString::fromLatin1("zsh")); |
| 304 | if (d->prog.isEmpty()) |
| 305 | // We're pretty much screwed, to be honest ... |
| 306 | d->prog = QString::fromLatin1("/bin/sh"); |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | # else |
| 312 | d->prog = QString::fromLatin1("/bin/sh"); |
| 313 | # endif |
| 314 | |
| 315 | d->args << QString::fromLatin1("-c") << cmd; |
| 316 | #else // Q_OS_UNIX |
| 317 | // KMacroExpander::expandMacrosShellQuote(), KShell::quoteArg() and |
| 318 | // KShell::joinArgs() may generate these for security reasons. |
| 319 | setEnv(PERCENT_VARIABLE, QLatin1String("%")); |
| 320 | |
| 321 | #ifndef _WIN32_WCE |
| 322 | WCHAR sysdir[MAX_PATH + 1]; |
| 323 | UINT size = GetSystemDirectoryW(sysdir, MAX_PATH + 1); |
| 324 | d->prog = QString::fromUtf16((const ushort *) sysdir, size); |
| 325 | d->prog += QLatin1String("\\cmd.exe"); |
| 326 | setNativeArguments(QLatin1String("/V:OFF /S /C \"") + cmd + QLatin1Char('"')); |
| 327 | #else |
| 328 | d->prog = QLatin1String("\\windows\\cmd.exe"); |
| 329 | setNativeArguments(QLatin1String("/S /C \"") + cmd + QLatin1Char('"')); |
| 330 | #endif |
| 331 | #endif |
| 332 | } |
| 333 | #endif |
| 334 | QStringListcxx . . $ QStringList# KProcesscxx . . $ KProcess#::programcxx . . $ KProcess#program(e1dbd5c4feadc8f5).() const |
| 335 | { |
| 336 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const KProcess); |
| 337 | |
| 338 | QStringListcxx . . $ QStringList# argv = d->argscxx . . $ KProcessPrivate#args.; |
| 339 | argv.prependcxx . . $ QList#prepend(77d9f17553126ecb).(d->progcxx . . $ KProcessPrivate#prog.); |
| 340 | return argv; |
| 341 | } |
| 342 | |
| 343 | void KProcesscxx . . $ KProcess#::startcxx . . $ KProcess#start(49f6e7a06ebc5aa8).() |
| 344 | { |
| 345 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 346 | |
| 347 | QProcesscxx . . $ QProcess#::startcxx . . $ QProcess#start(5e315ba9c811784d).(d->progcxx . . $ KProcessPrivate#prog., d->argscxx . . $ KProcessPrivate#args., d->openModecxx . . $ KProcessPrivate#openMode.); |
| 348 | } |
| 349 | |
| 350 | int KProcesscxx . . $ KProcess#::executecxx . . $ KProcess#execute(7864480464b09eea).(int msecs) |
| 351 | { |
| 352 | startcxx . . $ KProcess#start(49f6e7a06ebc5aa8).(); |
| 353 | if (!waitForFinishedcxx . . $ QProcess#waitForFinished(83c267b20bac841a).(msecs)) { |
| 354 | killcxx . . $ QProcess#kill(49f6e7a06ebc5aa8).(); |
| 355 | waitForFinishedcxx . . $ QProcess#waitForFinished(83c267b20bac841a).(-1); |
| 356 | return -2; |
| 357 | } |
| 358 | return (exitStatuscxx . . $ QProcess#exitStatus(15ed2eeed4841e77).() == QProcesscxx . . $ QProcess#::NormalExitcxx . . $ QProcess#NormalExit.) ? exitCodecxx . . $ QProcess#exitCode(455f465bc33b4cdf).() : -1; |
| 359 | } |
| 360 | |
| 361 | // static |
| 362 | int KProcesscxx . . $ KProcess#::executecxx . . $ KProcess#execute(e6dda02e784b26c5).(const QStringcxx . . $ QString# &exe, const QStringListcxx . . $ QStringList# &args, int msecs) |
| 363 | { |
| 364 | KProcesscxx . . $ KProcess# pcxx . . $ KProcess#KProcess(749de1b6ae65bddd).; |
| 365 | p.setProgramcxx . . $ KProcess#setProgram(4a8467afe4f213e4).(exe, args); |
| 366 | return p.executecxx . . $ KProcess#execute(7864480464b09eea).(msecs); |
| 367 | } |
| 368 | |
| 369 | // static |
| 370 | int KProcesscxx . . $ KProcess#::executecxx . . $ KProcess#execute(8beec924df336045).(const QStringListcxx . . $ QStringList# &argv, int msecs) |
| 371 | { |
| 372 | KProcesscxx . . $ KProcess# pcxx . . $ KProcess#KProcess(749de1b6ae65bddd).; |
| 373 | p.setProgramcxx . . $ KProcess#setProgram(631c0101495f0328).(argv); |
| 374 | return p.executecxx . . $ KProcess#execute(7864480464b09eea).(msecs); |
| 375 | } |
| 376 | |
| 377 | int KProcesscxx . . $ KProcess#::startDetachedcxx . . $ KProcess#startDetached(b126dc7c1de90089).() |
| 378 | { |
| 379 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KProcess); |
| 380 | |
| 381 | qint64cxx . . $ qint64# pid; |
| 382 | if (!QProcesscxx . . $ QProcess#::startDetachedcxx . . $ QProcess#startDetached(959386328895d4c).(d->progcxx . . $ KProcessPrivate#prog., d->argscxx . . $ KProcessPrivate#args., workingDirectorycxx . . $ QProcess#workingDirectory(6ef7b6c27b00b43d).(), &pid)) |
| 383 | return 0; |
| 384 | return (int) pid; |
| 385 | } |
| 386 | |
| 387 | // static |
| 388 | int KProcesscxx . . $ KProcess#::startDetachedcxx . . $ KProcess#startDetached(73e3de59a50b8b33).(const QStringcxx . . $ QString# &exe, const QStringListcxx . . $ QStringList# &args) |
| 389 | { |
| 390 | qint64cxx . . $ qint64# pid; |
| 391 | if (!QProcesscxx . . $ QProcess#::startDetachedcxx . . $ QProcess#startDetached(959386328895d4c).(exe, args, QStringcxx . . $ QString#QString(ced63f7c635d850d).(), &pid)) |
| 392 | return 0; |
| 393 | return (int) pid; |
| 394 | } |
| 395 | |
| 396 | // static |
| 397 | int KProcesscxx . . $ KProcess#::startDetachedcxx . . $ KProcess#startDetached(d9341dc6cfa53040).(const QStringListcxx . . $ QStringList# &argv) |
| 398 | { |
| 399 | QStringListcxx . . $ QStringList# args = argv; |
| 400 | QStringcxx . . $ QString# prog = args.takeFirstcxx . . $ QList#takeFirst(5f357b03ed472e5e).(); |
| 401 | return startDetachedcxx . . $ KProcess#startDetached(73e3de59a50b8b33).(prog, args); |
| 402 | } |