Bug 201714 - kdeinit does not close its standard input/output when daemonizing
Summary: kdeinit does not close its standard input/output when daemonizing
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kdeinit (show other bugs)
Version: 4.2
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-28 00:18 UTC by mdm
Modified: 2010-03-07 14:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mdm 2009-07-28 00:18:56 UTC
Version:            (using KDE 4.2.2)
OS:                Linux
Installed from:    Ubuntu Packages

ktradertest, designed to be used from shell scripts, starts kdeinit (with --suicide --new-startup) if it does not find one running already. However kdeinit does not then close its standard input and output, so if ktradertest is piped into, say, grep by the shell script, then grep will not exit until kdeinit also exits. kdeinit waits about 15 seconds before exiting in case there are any other clients that want to use it, so the shell script waits around for grep which is waiting for kdeinit. This makes ktradertest useless for its intended purpose!

I'm not sure whether kdeinit, ktradertest, or perhaps some library used by ktradertest to start kdeinit should truly be responsible for closing stdin/stdout in this scenario, but it should happen somewhere to fix this problem.

We ran into this problem with Chromium's default browser detection, which uses xdg-mime which uses ktradertest piped into grep. See http://code.google.com/p/chromium/issues/detail?id=17179 for reference.
Comment 1 Michael Pyne 2009-07-28 02:22:39 UTC
ktradertest itself is a KDE 3 utility which did not make the transition to KDE 4 (I presume due to us using shared-mime-info now).  The underlying kdeinit issue itself may still be a problem for other similar uses but I would think we don't want to just close stdin/stdout since the children processes which make up KDE would all be unable to send output to or receive output from a tty.

Perhaps the best route is to have kdeinit close stdin/stdout if it's not going to/from a tty?
Comment 2 Fathi Boudra 2009-07-28 12:44:21 UTC
ktradertest from KDE 3 can be found as ktraderclient in kdebase/runtime on KDE 4.
Comment 3 Oswald Buddenhagen 2010-03-07 14:45:25 UTC
SVN commit 1100408 by ossi:

redirect stdout to stderr

if we are forked from a command line tool (say, ktraderclient) which is
used in a pipe, us keeping open the inherited stdout is pretty fatal for
the usefulness of the pipe.
as we have no use for a real stdout (if any at all), just redirect it to
stderr.
we can't just close/redirect stderr, as this is where all "interesting"
output is going. so if somebody tries to use some tool's stderr in a
pipe, he'd still be out of luck.

BUG: 201714


 M  +4 -0      kinit.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1100408