unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: joakim@verona.se
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: how to wait for a process to be alive?
Date: Fri, 22 Oct 2010 14:18:06 +0200	[thread overview]
Message-ID: <87vd4upgjl.fsf@gmx.de> (raw)
In-Reply-To: m3ocam4mau.fsf@verona.se

joakim@verona.se 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.



      parent reply	other threads:[~2010-10-22 12:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22  9:19 how to wait for a process to be alive? joakim
2010-10-22  9:35 ` Lars Magne Ingebrigtsen
2010-10-22 12:18 ` Michael Albinus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vd4upgjl.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=emacs-devel@gnu.org \
    --cc=joakim@verona.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).