ports/51651: KDE 3.1.1a: KProcess' stdout redirection fails, if child uses sched_setscheduler

Heiner h.eichmann at gmx.de
Thu May 1 09:00:29 UTC 2003


>Number:         51651
>Category:       ports
>Synopsis:       KDE 3.1.1a: KProcess' stdout redirection fails. if child uses sched_setscheduler
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 01 02:00:27 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Heiner Eichmann <h.eichmann at gmx.de>
>Release:        FreeBSD 4.8-RC2
>Organization:
Sirius Cybernetics Corp.
>Environment:
System: FreeBSD 4.8-RC #2: Thu Apr  3 11:05:05 CEST 2003 root at 7of9.unimatrix-zero.borg:/usr/obj/usr/src/sys/MYKERNEL i386
7of9# ls /var/db/pkg/ | grep ^kde
kde-3.1.1
kdeadmin-3.1.1
kdeartwork-3.1.1
kdebase-3.1.1a
kdeedu-3.1.1
kdegames-3.1.1
kdegraphics-3.1.1
kdelibs-3.1.1a
kdemultimedia-3.1.1
kdenetwork-3.1.1
kdepim-3.1.1
kdeutils-3.1.1
kdevelop-2.1.5

>Description:
See attached file. Compile both programs. Testprog.c simply prints a line to stdout.

Test 1: execute testprog . it will print a line and execute.

Proctest calls testprog (using KProcess), redirects its output into a QString and
prints the collected output out.

Test 2: execute proctest. It prints out the same as above

Test 3: remove the comments in testprog's main, compile it again, give it the suid
flag(!!!!!) and repeat test 1 and 2.
Testprog prints out a line, proctest prints nothing!
The newly added line raises the priority of testprog. After doing it KProcess'
stdout redirection somehow misses the output.

The same tests work fine on a gentoo box, so I guess the problem BSD specific.

Why do I make this crazy tests? K3b (not in the ports so far) uses KProcess
to call cdrecord. If called with the parameter -prcap, cdrecord raises its
priority (rt_raisepri in testprog was stolen from cdrecords source code). 
On linux, K3b can analyze cdrecords output; on bsd it can't!

Heiner

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#       Makefile
#       proctest.cpp
#       testprog.c
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
Xall: proctest testprog
X
Xproctest: proctest.cpp proctest.moc
X#      gcc -o proctest  -I/usr/X11R6/include -I/usr/local/include -lqt-mt -L/usr/X11R6/lib -pthread -lkdecore -L/usr/local/lib proctest.cpp
X#      gcc -o proctest  -I/usr/X11R6/include -I/usr/local/include -lqthreads -pthread -lkdecore -L/usr/local/lib proctest.cpp
X       gcc -o proctest  -I/usr/X11R6/include -I/usr/local/include -lqtmcop -pthread -lkdecore -L/usr/local/lib proctest.cpp
X
Xproctest.moc: proctest.cpp
X       moc proctest.cpp -o proctest.moc
X
Xtestprog: testprog.c
X       gcc -o testprog testprog.c
END-of-Makefile
echo x - proctest.cpp
sed 's/^X//' >proctest.cpp << 'END-of-proctest.cpp'
X#include <qstring.h>
X#include <kprocess.h>
X
Xclass ProcTest : QObject
X{
X    Q_OBJECT
X    QString m_processOutput;
Xprivate slots:
X     void slotCollectStdout(KProcess *, char * data, int len);
Xpublic:
X    void test();
X};
X
X
Xvoid ProcTest::test()
X{
X    KProcess proc;
X//    proc << "/usr/local/bin/cdrecord" << "dev=0,4,0" << "-checkdrive";
X//    proc << "/usr/local/bin/cdrecord" << "dev=0,4,0" << "-prcap";
X    proc << "./testprog";
X    connect( &proc, SIGNAL(receivedStdout(KProcess *, char *, int)), this, SLOT(slotCollectStdout(KProcess *, char *, int)));
X    m_processOutput = "";
X    proc.start(KProcess::Block, KProcess::Stdout);
X    printf("%s\n", m_processOutput.latin1());
X}
X
X
Xvoid ProcTest::slotCollectStdout(KProcess *, char * data, int len)
X{
X    m_processOutput += QString::fromLocal8Bit(data, len);
X}
X
X
Xint main (int argc, char * argv[])
X{
X    ProcTest proc;
X    proc.test();
X    return 0;
X}
X
X#include "proctest.moc"
END-of-proctest.cpp
echo x - testprog.c
sed 's/^X//' >testprog.c << 'END-of-testprog.c'
X#include <sched.h>
X
Xint
Xrt_raisepri(pri)
X       int pri;
X{
X       struct sched_param scp;
X       memset(&scp, '\0', sizeof(scp));
X       scp.sched_priority = sched_get_priority_max(SCHED_RR) - pri;
X       if (sched_setscheduler(0, SCHED_RR, &scp) < 0) {
X               printf("WARNING: Cannot set RR-scheduler\n");
X               return (-1);
X       }
X       return (0);
X}
X
Xint main (int argc, char * argv[])
X{
X// Remove comments here for test 3!!!!!!!!!
X//    rt_raisepri(0);
X    printf("This is a testline\n");
X    return 0;
X}
X
END-of-testprog.c
exit



>How-To-Repeat:
see above
>Fix:



--Boundary-00=_p/Ns+z81e1wL0+w
Content-Type: application/x-tgz;
  name="KProcess.tar.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="KProcess.tar.gz"

H4sICIfcsD4AA0tQcm9jZXNzLnRhcgDtV1lvGzcQ1qv4K6YKmqzSXWnX1lGs7ACxG6RuXTuRDbRA
Uwg0l5JY7RUuV73g/97hXlIUtInrSk/8IEHkkHOQM/xIpTJhimeqx9K0tSe4nuuOBoOWW2L31xsN
vJY7Hg0H3mA8PMJ53tHRaNgCd18BbSPPFJUALZkk6t/m/bbkPDxEQIfFExGzMA84nLzPlBTxord8
QTbCVYr1wbNMSwkLaZbBG5TcYsWAD2+v737lTJG/CCDezq7Pvnt1flt2bgprEM0qC9e5SnM1IakU
a6o4ZGGiMr+YC+tEBIXgPAlDNHijgiRX1vdvSlV4bgNbYpaeQ0AVtUHECkIed9FafhcKVpoprOha
tnDgfkIIKSR1vL5fjlXRNsZ1fBPS72uhbsPJCXT6eSb7YcJo2L8TcZ8FkrNEBp1iMODrU9ce2G7Z
ddiSs1WA6+KdxxlKJaMp2vjAQq+v48buohphSRzjJlnwVM+x4ebi9dXLSwsNcwwh+MfNK/at27VB
LUWGapfXt9bnbHql1y297yQUTqGzFXFPn6aNEd8/w7WvbNgISjfdWgVNz63Ol9m7uGPv2u6FVInY
s7Tr+4/T+R8Kpsr97hq+Oq3r1ffnMokudb6+PhPKKtXLWtMhaEMRFTFYukXlgjWesLP++ZfaRXNK
yvJq9qeuTy2QXOUyBrcw3Zy5TlpTcpSwDtnz+a9rq8f25+MT/O+OvVHF/8OBO9b8742PPcP/h8CG
6jOksaDgeSxtItVMUpFxPKEWfrukrQseWxMs8DZeFTlTUKjMUipphO10QtoRjzKurKfYs+HZO/eZ
DZn4kydzCyX6HLfxt1fpSZFIof5ACikFC64a4Syiv1s359+++mY2nXbBKV23xRyscjK6KRp5yKXl
Ip1Vc23QzrtwAm4XMNR2zTE/vpxeXVy99uGcxnGCwXMF06nTGEEG0vG1q1NpOZ7u3pNG4JYc8FkU
gLfAlEfJmiNbRxGPVQZLLjnME1lcUXD8RY3qxtjecHeHHm+RsAE/tNANRczLYD8ikYfn/we64nMR
8v+/sjb41PvPbd5/Q88defr8Hx+Pzfk/BGgY+lDfOFDfBoTUos2g/ocA23cTedJeMAZOstEH56J4
8PzkedNRv6aWSli+ghph+F45kQLncksjFHfgpGopOQ1wxirQjyVezykN6DnbMT0+jMJd9nDHj/Ub
sSR9uFeynQN/JyIUfZiwrfCKnJE6xT5srv5mJbUIDvEsMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MNgD/gbJ7kMGACgAAA==

--Boundary-00=_p/Ns+z81e1wL0+w--

>Release-Note:
>Audit-Trail:
>Unformatted:
 --Boundary-00=_p/Ns+z81e1wL0+w
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 



More information about the freebsd-ports-bugs mailing list