Bug 135013

Summary: [KDE3] "/usr/bin/env bash" always runs in the background using high CPU
Product: [Applications] krfb Reporter: EssL <EssL.main>
Component: generalAssignee: Jaison Lee <lee.jaison>
Status: REOPENED ---    
Severity: normal CC: grundleborg, rdieter
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: MAC CRs to Unix LFs. No other changes.

Description EssL 2006-10-02 19:10:16 UTC
Version:            (using KDE KDE 3.5.4)
Installed from:    SuSE RPMs
Compiler:          gcc 4.1.0 
OS:                Linux

"/usr/bin/env bash??if [ "$1" = "--kinetd" ]; then??# redirect stdin and stdout bash" always runs in the background, after killing it - it disappears for some time and runs again using alot of CPU.
Comment 1 Philip Rodrigues 2006-10-02 20:42:29 UTC
Are you running krfb? Does the problem go away if you kill it? Does the problem also exist for a newly created user?
Comment 2 EssL 2006-10-02 21:30:58 UTC
It's the last thing I've tried before posting, killed it an hour ago, still waiting... (I've checked the ">dcop kded kinetd services" it returned "krfb_httpd, krfb" so I guess krfb is the problem...)
If it'll return I'll check for new users.
Thanks.
Comment 3 Modestas Vainius 2006-11-30 10:15:23 UTC
At least two of debian testing/unstable users are experiencing this problem as well. Relevant info here:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=401018
http://lists.debian.org/debian-kde/2006/11/msg00141.html
http://lists.debian.org/debian-kde/2006/11/msg00146.html
Comment 4 Reinhold Kainhofer 2007-01-28 21:56:36 UTC
*** This bug has been confirmed by popular vote. ***
Comment 5 Reinhold Kainhofer 2007-01-28 22:26:52 UTC
I have the same problem in Debian sid and in KUbuntu Edgy...

And then I looked at the file and saw that it uses Mac-style line breaks. If I change the line breaks to unix line breaks, the problem suddenly goes away!

Cheers,
Reinhold
Comment 6 Modestas Vainius 2007-01-29 08:55:33 UTC
Thank you Reinhold,

the bug will be fixed in debian sid (and probably etch) soon.
Comment 7 Modestas Vainius 2007-01-29 09:00:07 UTC
Created attachment 19468 [details]
MAC CRs to Unix LFs. No other changes.

A patch for this bug against kdenetwork 3.5.x
Comment 8 Bram Schoenmakers 2007-02-22 16:31:56 UTC
SVN commit 636245 by bram:

Replace Mac newlines with Unix newlines, and the problem of 100% CPU utilization with the first connection disappeared. Credits go to Reinhold and Modestas.

BUG:135013



 M  +75 -1     krfb_httpd  


--- branches/KDE/3.5/kdenetwork/krfb/krfb_httpd/krfb_httpd #636244:636245
@@ -1 +1,75 @@
-#! /usr/bin/env bash

if [ "$1" = "--kinetd" ]; then
	# redirect stdin and stdout to the inetd socket.
	exec <&$2 >&$2
fi

read request url httptype || exit 0
url="${url/
/}"
httptype="${httptype/
/}"

if [ "x$httptype" != "x" ]; then
	line="x"
	while [ -n "$line" ]; do
		read line || exit 0
		line="${line/
/}"
	done
fi
# echo "url = $url, request = $request" >> /tmp/httpd.log
case "$url" in
/)
	# We need the size of the display for the current applet.
	size=`xdpyinfo -display :0| grep dimensions:|head -n 1|sed -e "s/.*dimensions: *//" -e "s/ pixels.*//"`
	width=`echo $size|sed -e "s/x.*//"`
	height=`echo $size|sed -e "s/.*x//"`
	# The VNC menubar is 20 pixels high ...
	height=$((height+20))

	port=`dcop kded kinetd port krfb`
	if [ "$port" == "-1" ]; then
		port=5900
	fi

	ctype="text/html"
	content="
<HTML><HEAD><TITLE>$LOGNAME's desktop</TITLE></HEAD>
<BODY>
<APPLET CODE=VncViewer.class ARCHIVE=VncViewer.jar WIDTH=$width HEIGHT=$height>
	<param name=PORT value=$port>
</AP
 PLET>
</BODY></HTML>"
	;;
*.jar|*.class)
	# Use basename to make sure we have just a filename, not ../../...
	url="`basename "$url"`"
	ctype="application/octet-stream"
	cfile="/usr/share/vnc/classes/$url"
	content="FILE"
	;;
esac

if [ "x$httptype" != "x" ]; then
	echo "HTTP/1.0 200 OK"
	echo "Content-Type: $ctype"
	if [ "$content" == "FILE" ]; then
		clen=`wc -c "$cfile"`
	else
		clen=`echo "$content"|wc -c`
	fi
	echo "Content-Length: $clen"
	echo "Connection: close"
	echo
fi

if [ "$request" == "GET" ]; then
	if [ "$content" == "FILE" ]; then
		cat "$cfile"
	else
		echo "$content"
	fi
fi
exit 0
\ No newline at end of file
+#! /usr/bin/env bash
+
+if [ "$1" = "--kinetd" ]; then
+	# redirect stdin and stdout to the inetd socket.
+	exec <&$2 >&$2
+fi
+
+read request url httptype || exit 0
+url="${url/
+/}"
+httptype="${httptype/
+/}"
+
+if [ "x$httptype" != "x" ]; then
+	line="x"
+	while [ -n "$line" ]; do
+		read line || exit 0
+		line="${line/
+/}"
+	done
+fi
+# echo "url = $url, request = $request" >> /tmp/httpd.log
+case "$url" in
+/)
+	# We need the size of the display for the current applet.
+	size=`xdpyinfo -display :0| grep dimensions:|head -n 1|sed -e "s/.*dimensions: *//" -e "s/ pixels.*//"`
+	width=`echo $size|sed -e "s/x.*//"`
+	height=`echo $size|sed -e "s/.*x//"`
+	# The VNC menubar is 20 pixels high ...
+	height=$((height+20))
+
+	port=`dcop kded kinetd port krfb`
+	if [ "$port" == "-1" ]; then
+		port=5900
+	fi
+
+	ctype="text/html"
+	content="
+<HTML><HEAD><TITLE>$LOGNAME's desktop</TITLE></HEAD>
+<BODY>
+<APPLET CODE=VncViewer.class ARCHIVE=VncViewer.jar WIDTH=$width HEIGHT=$height>
+	<param name=PORT value=$port>
+</APPLET>
+</BODY></HTML>"
+	;;
+*.jar|*.class)
+	# Use basename to make sure we have just a filename, not ../../...
+	url="`basename "$url"`"
+	ctype="application/octet-stream"
+	cfile="/usr/share/vnc/classes/$url"
+	content="FILE"
+	;;
+esac
+
+if [ "x$httptype" != "x" ]; then
+	echo "HTTP/1.0 200 OK"
+	echo "Content-Type: $ctype"
+	if [ "$content" == "FILE" ]; then
+		clen=`wc -c "$cfile"`
+	else
+		clen=`echo "$content"|wc -c`
+	fi
+	echo "Content-Length: $clen"
+	echo "Connection: close"
+	echo
+fi
+
+if [ "$request" == "GET" ]; then
+	if [ "$content" == "FILE" ]; then
+		cat "$cfile"
+	else
+		echo "$content"
+	fi
+fi
+exit 0
Comment 9 Kevin Kofler 2008-02-22 18:46:39 UTC
Looks like this fix went too far, there are 3 characters in that script which should be literal ^M (\r) characters. (Yes, the script apparently _requires_ mixed line endings. Yuck!)

See: https://bugzilla.redhat.com/show_bug.cgi?id=433510#c5
Comment 10 Rex Dieter 2008-02-22 19:52:59 UTC
confirmed.