Expand description
Single-instance IPC for tree-space.
Launching tree-space while an instance is already running must hand the
new invocation’s intent to that instance (toggle visibility, open a pane,
choose a dock side) rather than starting a second panel. GApplication’s own
single-instance machinery can’t carry our --side flag or directory
arguments through the freshly-launched process cleanly, so we use a small
Unix domain socket under the runtime directory:
- The first instance binds the socket and runs an accept thread that
decodes each incoming line into a
Commandand hands it to the app. - Later instances try to connect; on success they write their serialized
Commandand exit without ever touching the GUI. - A stale socket (crashed instance) is detected by a failed connect and removed before re-binding.
Functions§
- bind
- Bind the instance socket as the (single) server.
- bind_at
- Bind the instance socket at an explicit path (see
bind). - deliver
- Try to deliver
cmdto a running instance. Returnstruewhen a server accepted the request;falsewhen no server is listening. - deliver_
at - Deliver
cmdto the server listening onpath. - socket_
path - Path of the instance socket for the current environment.
- spawn_
listener - Spawn a thread that accepts instance connections and forwards every decoded
Commandtodeliver(which must hop onto the UI thread itself, e.g. viaMainContext::invoke).