Xpra: Ticket #1114: xpra --start-child xterm starts in / and does not respect .Xresources

All's in the title: after

xpra start ssh:username@server:100 --start-child xterm

xterm starts in / (root) (I'd expect starting in $HOME instead) and uses a white background, even though my .Xresources (which work fine locally) specify otherwise.

Arch Linux regular package, xpra 0.16.1.

Mon, 08 Feb 2016 06:54:10 GMT - Antoine Martin: status, description, milestone changed

You can get the Xresources applied by running:

xpra start ssh:localhost --start-child xterm --start='xrdb -merge ~/.Xresources'

And obviously, you can achieve the same thing by adding this line to your /etc/xpra/xpra.conf:

start = xrdb -merge ~/.Xresources

Or use a session script or whatever. r11884 now includes an xrdb example in the default config file.

I am not convinced that it is xpra's job to choose what gets applied and what doesn't. Especially in this case where the client's xrdb does get synchronized already. Whatever xrdb settings I have on the client do get applied in the server session, just too late for start-child which gets run as soon as the server starts. If I start another xterm from the initial xterm, I see that the settings have been applied.

It would be nice if we waited for the client to connect and apply its settings (xdb, dpi, screen resolution, keyboard settings, etc) before executing the start / start-child commands. Or at least have the option to do that.

Maybe a --start-after-connect flag, which would be set automatically when using ssh start, since we know that the client will be connecting. (though we would need to do this via an environment variable instead of a command line because when the client generates the remote command line, it has no way of knowing if the server is going to support newer command line options..)

As for the current working directory being "/", this one is caused by the daemonize code which calls chdir("/"). I didn't want to just remove that line as this is what every other daemon code does.. So r11885 saves the cwd before daemonizing and uses it when starting commands. This will be backported to older versions. (the start-after-connect change, if I ever get around to it, will not)

Mon, 08 Feb 2016 08:28:10 GMT - Antony Lee:

xpra start ssh:localhost --start-child xterm --start='xrdb -merge ~/.Xresources'

works and is a reasonable workaround for now, although I'm a bit confused as to why the commands seem to be executed in reverse order (i.e.,

xpra start ssh:localhost --start='xrdb -merge ~/.Xresources' --start-child xterm


I do vote in favor of "--start-after-connect", which makes sense as you say.

On a side note, in the xpra man page, the SYNOPSIS entry for "xpra start" does not list the "--start" option (just the "--start-child" one).

Wed, 17 Feb 2016 15:15:39 GMT - Antoine Martin: owner, status changed

start-after-connect implemented in r11972.

@anntzer: please close if this works for you.

Thu, 18 Feb 2016 23:08:31 GMT - Antony Lee:

Latest SVN version (both on the server and the client) actually segfaults for me, regardless of whether I pass --start-after-connect or not.

Fri, 19 Feb 2016 02:33:31 GMT - Antoine Martin:

segfaults for me...

Do you have any debug output or gdb backtrace? I obviously cannot reproduce this.

Fri, 19 Feb 2016 03:04:37 GMT - Antony Lee:

Here we go

(gdb) r /usr/bin/xpra start ssh:antony@maxwell:100 --start-child xterm
Starting program: /usr/bin/python2 /usr/bin/xpra start ssh:antony@maxwell:100 --start-child xterm
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7de40b0 in do_lookup_x () from /lib64/ld-linux-x86-64.so.2
(gdb) bt
#0  0x00007ffff7de40b0 in do_lookup_x () from /lib64/ld-linux-x86-64.so.2
#1  0x00007ffff7de4d3f in _dl_lookup_symbol_x () from /lib64/ld-linux-x86-64.so.2
#2  0x00007ffff7de6985 in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
#3  0x00007ffff7dee7b9 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#4  0x00007ffff7dea124 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#5  0x00007ffff7dedfd1 in _dl_open () from /lib64/ld-linux-x86-64.so.2
#6  0x00007ffff723dfc9 in ?? () from /usr/lib/libdl.so.2
#7  0x00007ffff7dea124 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#8  0x00007ffff723e5e1 in ?? () from /usr/lib/libdl.so.2
#9  0x00007ffff723e061 in dlopen () from /usr/lib/libdl.so.2
#10 0x00007ffff7b230de in _PyImport_GetDynLoadFunc () from /usr/lib/libpython2.7.so.1.0
#11 0x00007ffff7b0945f in _PyImport_LoadDynamicModule () from /usr/lib/libpython2.7.so.1.0
#12 0x00007ffff7b0740c in import_submodule () from /usr/lib/libpython2.7.so.1.0
#13 0x00007ffff7b07959 in ensure_fromlist () from /usr/lib/libpython2.7.so.1.0
#14 0x00007ffff7b081ce in PyImport_ImportModuleLevel () from /usr/lib/libpython2.7.so.1.0
#15 0x00007ffff7ae873c in builtin___import__ () from /usr/lib/libpython2.7.so.1.0
#16 0x00007ffff7a4efe7 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#17 0x00007ffff7aea61b in PyEval_CallObjectWithKeywords () from /usr/lib/libpython2.7.so.1.0
#18 0x00007ffff7aed97f in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#19 0x00007ffff7af5393 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#20 0x00007ffff7af54cc in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0
#21 0x00007ffff7b063e4 in PyImport_ExecCodeModuleEx () from /usr/lib/libpython2.7.so.1.0
#22 0x00007ffff7b0667d in load_source_module () from /usr/lib/libpython2.7.so.1.0
#23 0x00007ffff7b07c50 in load_package () from /usr/lib/libpython2.7.so.1.0
#24 0x00007ffff7b0740c in import_submodule () from /usr/lib/libpython2.7.so.1.0
#25 0x00007ffff7b0768f in load_next () from /usr/lib/libpython2.7.so.1.0
#26 0x00007ffff7b08107 in PyImport_ImportModuleLevel () from /usr/lib/libpython2.7.so.1.0
#27 0x00007ffff7ae873c in builtin___import__ () from /usr/lib/libpython2.7.so.1.0
#28 0x00007ffff7af22be in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#29 0x00007ffff7af1fbd in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#30 0x00007ffff7af1fbd in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#31 0x00007ffff7af1fbd in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#32 0x00007ffff7af1fbd in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#33 0x00007ffff7af5393 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#34 0x00007ffff7af54cc in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0
#35 0x00007ffff7b104f3 in run_mod () from /usr/lib/libpython2.7.so.1.0
#36 0x00007ffff7b117a2 in PyRun_FileExFlags () from /usr/lib/libpython2.7.so.1.0
#37 0x00007ffff7b12ad9 in PyRun_SimpleFileExFlags () from /usr/lib/libpython2.7.so.1.0
#38 0x00007ffff7b25b05 in Py_Main () from /usr/lib/libpython2.7.so.1.0
#39 0x00007ffff7461610 in __libc_start_main () from /usr/lib/libc.so.6
#40 0x0000555555554859 in _start ()

Fri, 19 Feb 2016 03:08:16 GMT - Antoine Martin:

@anntzer: this is not related to this ticket and is very likely to be something caused by Arch - there is not one line related to xpra in this whole backtrace.

Mon, 22 Feb 2016 14:07:50 GMT - Antoine Martin: owner changed

I was playing with start and start-after-connect as part of #1132 and I didn't like the limitations of the implementation in r11972. So r12009 generalizes it and allows 6 different start options:

And we now expose this and more via xpra info too. Here's an example I used for testing:

xpra start :100 --daemon=no --bind-tcp= \
    --start-child="xterm -bg yellow" \
    --start-after-connect="xterm -bg red" \
    --start-child-on-connect="xterm -bg green" \

You will get a yellow, a green and a red xterm when you connect. A new green one will be started every time you connect. Exiting the yellow and all the green ones will terminate the session. And here's the xpra info for it:

$ xpra info | grep ^commands
commands.start-after-connect=('xterm -bg red',)
commands.start-child=('xterm -bg yellow',)
commands.start-child-on-connect=('xterm -bg green',)

@afarr: I believe the stacktrace in comment:6 is bogus / not caused by xpra, so this is a FYI (not sure you can find a use for it) - feel free to close.

Mon, 29 Feb 2016 05:13:20 GMT - Antoine Martin: milestone changed

Thu, 19 May 2016 00:36:21 GMT - alas: status changed; resolution set

Wow... it's like xterm Christmas!

Looks good, and some of these options may be very useful to know about.


Sat, 23 Jan 2021 05:15:21 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1114