File indexing completed on 2024-02-25 03:58:49

0001 /*
0002     This file is part of the KDE libraries
0003 
0004     SPDX-FileCopyrightText: 2007 Oswald Buddenhagen <ossi@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "kprocesstest_helper.h"
0010 #include <kprocess.h>
0011 
0012 #include <stdio.h>
0013 #include <stdlib.h>
0014 
0015 int main(int argc, char **argv)
0016 {
0017     if (argc < 2) {
0018         printf("Missing parameter");
0019         return -1;
0020     }
0021     KProcess p;
0022     p.setShellCommand(QString::fromLatin1("echo " EOUT "; echo " EERR " >&2"));
0023     p.setOutputChannelMode(static_cast<KProcess::OutputChannelMode>(atoi(argv[1])));
0024     fputs(POUT, stdout);
0025     fflush(stdout);
0026     p.execute();
0027     fputs(ROUT, stdout);
0028     fputs(p.readAllStandardOutput().constData(), stdout);
0029     fputs(RERR, stdout);
0030     if (p.outputChannelMode() != KProcess::MergedChannels) {
0031         fputs(p.readAllStandardError().constData(), stdout);
0032     }
0033     return 0;
0034 }