Subject: Fwd: [X2Go-Dev] Patch: x2goserver: x2goruncommand - set IMEXIT="true" for gnome-terminal

From: Mihai Moldovan <[email-masked]>
Date: Tue, 17 Mar 2015 06:41:10 +0100

Package: x2goserver
Version 4.0.1.19
Tag: patch
Submitter: Rok Mandeljc <[email-masked]>

-------- Forwarded Message --------
Subject: 	[X2Go-Dev] Patch: x2goserver: x2goruncommand - set
IMEXIT="true" for gnome-terminal
Date: 	Mon, 16 Mar 2015 23:01:05 +0100
From: 	Rok Mandeljc <[email-masked]>
To: 	[email-masked]

Hello,

I have been trying to set up x2goserver on my Fedora 21 boxes, and
gnome-terminal seems to be failing with symptoms similar to those
described in #268.

It seems that x2goruncommand has been reworked a bit since that patch,
and now attempts to force the forking programs to stay in the foreground
by capturing their output to STDOUT. Unfortunately, this does not seem
to work for gnome-terminal; the terminal window appears on the client
for a second, then closes and the session is proclaimed to be finished.
This can be fixed by explicitly setting IMEXIT="true" if called binary
is gnome-terminal, which is done by the attached patch.

Regards,
    Rok

From 55078582d8ed695b44c0bb564765636326c0c0f3 Mon Sep 17 00:00:00 2001
From: Rok Mandeljc <[email-masked]>
Date: Mon, 16 Mar 2015 22:41:12 +0100
Subject: [PATCH] x2goruncommand: set IMEXIT="true" if called binary is
 gnome-terminal

The STDOUT trick used by x2goruncommand to keep programs that fork
to background (sort of) in the foreground does not seem to have
the desired effect with gnome-terminal on Fedora 21. To make it
work, IMEXIT needs to be set to "TRUE".
---
 x2goserver/bin/x2goruncommand | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/x2goserver/bin/x2goruncommand b/x2goserver/bin/x2goruncommand
index ac7ff7f..5bda27b 100755
--- a/x2goserver/bin/x2goruncommand
+++ b/x2goserver/bin/x2goruncommand
@@ -274,6 +274,14 @@ then
 	fi
 fi
 
+# A work-around for gnome-terminal; the application quits immediately,
+# and we cannot keep it in foreground with STDOUT trick
+if [ "$BNAME" == "gnome-terminal" ]
+then
+        IMEXIT="true"
+fi
+
+
 if [ "$X2GO_SESS_TYPE" == "P" ]
 then
 	IMEXIT="true"
-- 
2.1.0

---

From: Mihai Moldovan <[email-masked]>
Date: Tue, 17 Mar 2015 07:02:31 +0100

Control: submitter -1 Rok Mandeljc <[email-masked]>
Thanks

> is gnome-terminal, which is done by the attached patch.

This looked weird at first glance, because you've previously (two years
ago) sent a patch to explicitly disable IMEXIT for GNOME Terminal.

However, Mike#1 changed the IMEXIT behavior with commit
c3afe1c154dfeb0ba052f7506f0cadc5f6c62871 and that's also why it's now
failing for GNOME Terminal.

I'll be adding IMEXIT="true" and your comment where gnome-terminal is
defined, if that's OK with you?

Will craft and commit a patch tomorrow.

Thanks for contributing!

Mihai

N.B.: shouldn't this be also required for KDE4's konsole? Looks like it,
but I'm not a KDE user, so... input welcome.

---

From: Rok Mandeljc <[email-masked]>
Date: Tue, 17 Mar 2015 11:09:02 +0100

> failing for GNOME Terminal.

Indeed :)

> defined, if that's OK with you?

If you are talking about the if [ "$cmd" == "TERMINAL" ] switch, then I
think it will not fix the case when session is "single command" and the
"gnome-terminal" is manually entered as a binary (with or without path).
I use such session definition on couple of workstations that have both
KDE and GNOME installed to get gnome-terminal instead of konsole... Not
sure how wide-spread that use case is, though; or if it could perhaps be
done better?

> but I'm not a KDE user, so... input welcome.

Capturing konsole's output to STDOUT seems to do the trick, at least at
the moment. So for now, it works correctly without setting IMEXIT.

Regards,
    Rok

---

From: Mihai Moldovan <[email-masked]>
Date: Tue, 17 Mar 2015 15:43:15 +0100

On 17.03.2015 11:09 AM, Rok Mandeljc wrote:
> [...]

Yes, you're right and that makes sense.

As a side note, luckily, published applications are always handled with
IMEXIT, so these are good.

>> [...]

OK, thanks!

---

From: Mike Gabriel <[email-masked]>
Date: Tue, 17 Mar 2015 16:05:03 +0000

Hi all,

>> the moment. So for now, it works correctly without setting IMEXIT.

With gnome-terminal from GNOMEv2 IMEXIT needs to be false (because  
gnome-terminal (v2) does _not_ fork to background).

With gnome-terminal from GNOMEv3 IMEXIT needs to be true (because  
gnome-terminal (v3) forks to background).

Mike
-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: [email-masked], http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb

---

From: Mihai Moldovan <[email-masked]>
Date: Fri, 20 Mar 2015 05:53:09 +0100

> gnome-terminal (v3) forks to background).

Stefan just "submitted" another bug report yesterday in a private
conversion about another piece of software that needs special handling
via IMEXIT -- but likewise different values dependent on the specific
version used.

I guess I should better handle that with a few new functions, to be able
to add other software and versions more flexible in the future.

Mihai

P.S.: a workaround for those issues is to use pubapps.

---

From: Mike Gabriel <[email-masked]>
Date: Fri, 20 Mar 2015 11:17:15 +0000

> P.S.: a workaround for those issues is to use pubapps.

Before you start working on this...

Actually, the x2goruncommand stuff should be fully reworked. So that  
TERMINAL, WEBBROWSER etc. are actually symlinks or .desktop files that  
the x2goruncommand refers to.

Basically, I would fork every single application to background and  
monitor its termination with other means (e.g. with the stdout/stderr  
blocker), so that IMEXIT would always be FALSE.

Mike
-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy: