[Parti-discuss] Patch: have "xpra start" optionally start a client application

Nathaniel Smith njs at pobox.com
Fri Aug 8 04:42:42 EDT 2008


2008/7/19 Robert Tate <wrtate at users.sourceforge.net>:
> Neat project!
>
> Attached is a patch for your consideration.  It adds an optional
> argument to the "xpra server" sub-command to run a specified command
> (presumably an X client application); when this application exits, the
> server is terminated (unless --no-automatic-stop was specified).
>
> Sample usages:  (Note:  a -- is required before the command if it
> contains any options starting with a -.)
>     xpra start :20 -- xterm -fn 10x20
>     xpra --no-automatic-stop start :20 xterm

Neat patch!  Rather than overload the meaning of positional arguments,
I think I like a UI like:
  xpra start :20 --with-child="xterm -fn 10x20"

This also allows for people to specify multiple programs if they want
that for some reason.

Comments for future reference:

> +            pid,status=posix.waitpid(-1,posix.WNOHANG)
^^ pleasetrytousespacesitmakesthingsmorereadable

> +                                 + "\t%prog start DISPLAY [ [--no-automatic-stop] -- command]\n"
^^ we don't normally put options explicitly into the synopsis like
this, since putting them all in would take too much space, and
duplicate the automatically generated --help besides.

> +                      help="Don't terminate server when client on start command exits")
^^ Probably better to avoid referring to these as "clients", since
that term becomes overloaded ('xpra attach' is also a client, but a
very different sort).  My version uses "child" instead; maybe there's
a better term yet?

> import posix
^^ Why use posix explicitly, instead of just os?  (On posix systems
posix is an alias for os.)

I also rewrote the process spawning loop to use the subprocess module
instead of fork()/exec() directly, and factored out the (now more
complicated by the addition of multiple-child support) child reaping
functionality into an object, instead of having it refer to global
state.

Revised patch attached, also committed as
0490573b05ba466a373ee6380c24c266423dffd6 on branch
org.vorpus.parti.spawn-children.  Now I just need to test it...

-- Nathaniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xpra_start_client-2.patch
Type: text/x-diff
Size: 4483 bytes
Desc: not available
Url : http://lists.partiwm.org/pipermail/parti-discuss/attachments/20080808/bf2f138e/attachment.patch 


More information about the Parti-discuss mailing list