After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 631589 - set_emulation does not work in the python bindings
set_emulation does not work in the python bindings
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
0.26.x
Other Linux
: Normal major
: ---
Assigned To: VTE Maintainers
VTE Maintainers
: 630861 631317 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-10-07 08:52 UTC by Simon Schampijer
Modified: 2010-10-13 20:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Pass the correct TERM value inside envp when spawning (4.74 KB, patch)
2010-10-07 11:00 UTC, Tomeu Vizoso
none Details | Review
Pass the correct TERM value inside envp when spawning (4.25 KB, patch)
2010-10-07 14:25 UTC, Tomeu Vizoso
none Details | Review
Pass the correct TERM value inside envp when spawning (3.76 KB, patch)
2010-10-08 07:02 UTC, Tomeu Vizoso
none Details | Review
Pass the correct TERM value inside envp when spawning (4.77 KB, patch)
2010-10-08 07:18 UTC, Tomeu Vizoso
committed Details | Review

Description Simon Schampijer 2010-10-07 08:52:09 UTC
When I use set_emulation to set the terminal it has no effect, the system env TERM variable is used instead. 

For example I start the vte-demo.py from another terminal where TERM is set to dumb. The TERM variable in the vte-demo.py is then set to dumb, too - even so set_emulation does set it to xterm in this demo program. 

In 0.24 when I do the same thing, and print out the TERM variable in vte-demo.py it is set to xterm.

This has an impact on the terminal activity in Sugar: http://bugs.sugarlabs.org/ticket/2394
Comment 1 Tomeu Vizoso 2010-10-07 11:00:08 UTC
Created attachment 171886 [details] [review]
Pass the correct TERM value inside envp when spawning

Previously we were removeing TERM from envp and calling setenv from
vte_pty_child_setup but it had no effect because execve would rewrite
the whole environment with whatever we passed as envp.
Comment 2 Christian Persch 2010-10-07 11:11:53 UTC
This patch is wrong, since using __vte_pty_spawn/vte_terminal_fork_command[_full] isn't required to use VtePty, it's just a convenience API.
Comment 3 Tomeu Vizoso 2010-10-07 12:51:43 UTC
(In reply to comment #2)
> This patch is wrong, since using
> __vte_pty_spawn/vte_terminal_fork_command[_full] isn't required to use VtePty,
> it's just a convenience API.

Thanks for looking at it, could you be more specific about which codepaths this patch breaks? This is the first time I look at vte.
Comment 4 Christian Persch 2010-10-07 13:16:32 UTC
It breaks if you use vte_pty_child_setup (with fork, or g_spawn_async*) directly, instead of the vte_terminal_fork_command* convenience APIs.
Comment 5 Tomeu Vizoso 2010-10-07 14:25:20 UTC
Created attachment 171896 [details] [review]
Pass the correct TERM value inside envp when spawning

So the codepaths that end up invoking execve still have the correct
TERM entry.
Comment 6 Christian Persch 2010-10-07 14:36:03 UTC
Had a quick look at the new patch, that looks better. However, I don't quite understand where the bug actually IS; we set the TERM var in child_setup, where is it overwritten it after that?
Comment 7 Tomeu Vizoso 2010-10-07 14:45:54 UTC
(In reply to comment #6)
> Had a quick look at the new patch, that looks better. However, I don't quite
> understand where the bug actually IS; we set the TERM var in child_setup, where
> is it overwritten it after that?

g_spawn_async_with_pipes() will end up calling execve() which discards the existing environment:

http://git.gnome.org/browse/glib/tree/glib/gspawn.c#n1103
Comment 8 Christian Persch 2010-10-07 17:32:39 UTC
Hmm right. So the approach of this patch looks right.

+        if (term_value != NULL)
+                g_ptr_array_add (array, g_strconcat ("TERM", "=", term_value, NULL));

I'd rather put this into the hash table after iterating over parent_environ (a few lines above this place), and keep the hash table to ptr array code as-is.

And let's add a few words in the documentation for VtePty about this issue, so one knows what to do when using vte_pty directly with g_spawn_async without using the vte_terminal_fork_command* wrapper.
Comment 9 Behdad Esfahbod 2010-10-07 18:29:53 UTC
*** Bug 630861 has been marked as a duplicate of this bug. ***
Comment 10 Tomeu Vizoso 2010-10-08 07:02:44 UTC
Created attachment 171942 [details] [review]
Pass the correct TERM value inside envp when spawning

So the codepaths that end up invoking execve still have the correct
TERM entry.
Comment 11 Tomeu Vizoso 2010-10-08 07:18:44 UTC
Created attachment 171943 [details] [review]
Pass the correct TERM value inside envp when spawning

So the codepaths that end up invoking execve still have the correct
TERM entry. Clarify the effect of vte_pty_set_term().
Comment 12 Behdad Esfahbod 2010-10-08 15:08:20 UTC
ChPe, can we get this in if it looks good now?
Comment 13 Christian Persch 2010-10-08 15:17:47 UTC
Yes, this looks good now (apart from the documentation issue which I can amend later). 

Ok to commit to master and vte-0-26.
Comment 14 Tomeu Vizoso 2010-10-08 16:22:19 UTC
Attachment 171943 [details] pushed as e5fd6c3 - Pass the correct TERM value inside envp when spawning
Comment 15 Simon Schampijer 2010-10-11 18:47:51 UTC
Thanks everyone for working on this! 

Do you already have plans when to do a new release of the 0.26 branch? I ask because in one week there is the F14 Final Change deadline and we either try to ship a patch but a bug fix release is preferred of course.
Comment 16 Christian Persch 2010-10-11 19:12:33 UTC
See http://live.gnome.org/TwoPointThirtythree for the GNOME release schedule for 2.32.1 .

Unless you think we should get a 2.26.0.1 out just for this fix --- Behdad?
Comment 17 Simon Schampijer 2010-10-11 19:39:27 UTC
Thanks Christian for your reply. 2.32.1 is still a bit out, indeed.

Sugar was originally aligned with the GNOME schedule but we added another bug fix release ( http://wiki.sugarlabs.org/go/0.90/Roadmap#Schedule ) for this Friday ourselves to get a few more fixes into F14.
Comment 18 Jonh Wendell 2010-10-11 19:47:52 UTC
*** Bug 631317 has been marked as a duplicate of this bug. ***
Comment 19 Behdad Esfahbod 2010-10-13 15:45:23 UTC
(In reply to comment #16)
> See http://live.gnome.org/TwoPointThirtythree for the GNOME release schedule
> for 2.32.1 .
> 
> Unless you think we should get a 2.26.0.1 out just for this fix --- Behdad?

Released 2.26.1.
Comment 20 Simon Schampijer 2010-10-13 20:00:45 UTC
(In reply to comment #19)
> (In reply to comment #16)
> > See http://live.gnome.org/TwoPointThirtythree for the GNOME release schedule
> > for 2.32.1 .
> > 
> > Unless you think we should get a 2.26.0.1 out just for this fix --- Behdad?
> 
> Released 2.26.1.

Thanks for the bug fix release, has been found it's way into a F14 update already. Works great!

Thanks as well to Tomeu for the actual code!