Gnus development mailing list
 help / color / mirror / Atom feed
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Preventing multiple startups of Gnus by the same user?
Date: 07 Mar 2000 23:18:08 -0500	[thread overview]
Message-ID: <ltr9dmjdrz.fsf@asfast.com> (raw)
In-Reply-To: Andrew J Cosgriff's message of "07 Mar 2000 15:35:19 +1100"

Andrew J Cosgriff <ajc@bing.wattle.id.au> writes:

> Lloyd Zusman wrote :
> 
> > Suppose I have started up XEmacs as a certain user on my machine,
> > and this XEmacs process is running Gnus.  [ ... ]
> > [ ... ] What I'd like to do is for
> > this second Gnus to never start up because there's another one
> > running as the same user ID within a different process.
> > 
> > [ ... ]
> 
> Do you run gnuserv ?  Only one instance of gnuserv can run per user,
> so if you start it a second time in a second copy of emacs it'll die
> straight away - perhaps just before you try starting gnuserv in your
> .emacs you could run "gnuclient -eval '(gnus-alive-p)'" and see what
> it says - if there's already a copy of XEmacs running gnuserv that's
> running gnus, it'd work.

Thanks for this suggestion.  I do run gnuserv and hadn't thought of
this, and I was able to code up something that works pretty much
the way you suggest.

However, this approach has a race condition that I don't know how to
get rid of.  To explain the race condition, I first have to show you
my new Gnus startup code:

  (gnuserv-start)
  (sit-for 3)
  (cond
   ((eq (process-status gnuserv-process) 'run)
    (gnus))
   (t
    (message "user %s: another Gnus is running" (user-login-name))))

It turns out that `gnuserv-start' returns right away, before the
gnuserv executable itself can determine whether there's another
instance of itself running or not.  Right after `gnuserv-start'
returns, the status of that process is always "run".  Only after a
short while does the status change to "error" if there's another
gnuserv process.

I looked through the gnuserv.el elisp code and there doesn't seem to
be any way to avoid this race condition.  Even `gnuserv-init-hook'
doesn't help me, because it too is affected by the same race condition
(i.e., I'd have to wait a couple seconds inside of that routine also
in order to detect whether or not the gnuserv process failed).

I can live with this race condition, since the code I wrote works
and I can always increase the `sit-for' time.  But is there any
way to eliminate this race condition altogether? ... or maybe
yet another approach to accomplish what I want?


> [ ... ]
> 
> HTH.

Indeed is has helped, since as I mentioned, I can minimize the effects
of the race condition.  Thank you very much!

-- 
 Lloyd Zusman
 ljz@asfast.com



  reply	other threads:[~2000-03-08  4:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-07  3:49 Lloyd Zusman
2000-03-07  3:55 ` Karl Kleinpaste
2000-03-07  4:04   ` Lloyd Zusman
2000-03-07  4:35     ` Andrew J Cosgriff
2000-03-08  4:18       ` Lloyd Zusman [this message]
2000-03-07 20:47     ` Jan Vroonhof
2000-03-08  4:20       ` Lloyd Zusman

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

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

  git send-email \
    --in-reply-to=ltr9dmjdrz.fsf@asfast.com \
    --to=ljz@asfast.com \
    /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.
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 NNTP newsgroup(s).