[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to wait for a process to be alive?
From: |
Michael Albinus |
Subject: |
Re: how to wait for a process to be alive? |
Date: |
Fri, 22 Oct 2010 14:18:06 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
address@hidden writes:
> I'm working on a mode to integrate Inkscape and Emacs. So far its only
> rudimentary.
>
> I want to start Inkscape from Emacs, with code looking like this:
>
> | (defun inkscape-start ()
> | (interactive)
> | (if (not (dbus-ping :session "org.inkscape" 100))
dbus-ping has the side effect to start a service, if it doesn't run yet,
and if it has provided a service file (located under
/usr/share/dbus-1/services). This would already be a good way to start
the process, if such a service file exists.
If you want to check only, whether Inkscape is running, you could call
(dbus-get-name-owner :session "org.inkscape")
> I suppose the sleep-for is interupted by some kind of event, but I cant
> figure out which, or how to do this properly. The best would be for
> Inkscape to send Emacs some kind of event rather than Emacs polling
> Inkscape, but I'm not sure how to do that either.
Register for the D-Bus signal org.freedesktop.DBus.NameOwnerChanged. You
will get signals like this:
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=8
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;
member=NameOwnerChanged
string ":1.97"
string ""
string ":1.97"
With the same dbus-get-name-owner as above call you can check, whether
Inkscape is already started.
Best regards, Michael.