xwem-devel
[Top] [All Lists]

Re: patch-41 xwem-agent doesn't work for me

From: Zajcev Evgeny <zevlg@xxxxxxxxx>
Subject: Re: patch-41 xwem-agent doesn't work for me
Date: Thu, 31 Mar 2005 10:05:14 +0400
User-agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux)
Zajcev Evgeny <zevlg@xxxxxxxxx> writes:

> Steve Youngs <steve@xxxxxxxx> writes:
>
>> * Steve Youngs <steve@xxxxxxxx> writes:
>>
>>   > With xwem-agent.c that is in xwem--main--2.1--patch-41 I can't use
>>   > XWEM.
>>

Steve, please try out this patch - it makes sure that no other
(S)XEmacs instance is running when starting emacs.

--- orig/xwem-agent/xwem-agent.c
+++ mod/xwem-agent/xwem-agent.c
@@ -115,11 +115,11 @@
 char *outfile = NULL;
 
 enum {
-        STATE_WAITINNG,
+        STATE_WAITING,
         STATE_RUNNING,
         STATE_KILLING
 };
-static int state = STATE_WAITINNG;      /* xwem-agent current state */
+static int state = STATE_WAITING;      /* xwem-agent current state */
 
 /*
  * Evil hackery do display verbose logs
@@ -158,6 +158,12 @@
 pid_t
 start_emacs()
 {
+        if (epid > 0) {
+                /* Already running emacs */
+                xverbose("  - (S)XEmacs already running, not starting");
+                return -1;
+        }
+
         if ((epid = fork()) == 0) {
                 setenv("XWEM_RUNNING", "notyet", 1);
 
@@ -179,6 +185,10 @@
                         }
                 }
 
+                /* Remove signal handlers */
+                signal(SIGCHLD, SIG_DFL);
+                signal(SIGHUP, SIG_DFL);
+
                 execvp(emacs, emacs_argv);
 
                 /* Execve failed :( */
@@ -223,10 +233,11 @@
         XSetInputFocus(xdpy, PointerRoot, RevertToPointerRoot, CurrentTime);
         xverbose("  + InputFocus set to PointerRoot ..");
 
-        if ((state == STATE_KILLING) || autodetect)
-                start_emacs();
-        else
-                state = STATE_WAITINNG;
+        if ((state == STATE_KILLING) || autodetect) {
+                if (start_emacs() < 0)
+                        state = STATE_WAITING;
+        } else
+                state = STATE_WAITING;
 }
 
 void
@@ -333,7 +344,7 @@
         xverbose("  + Magic keys at C-Sh-ESC(exit), C-Sh-F6(SIGABORT),"
                  " C-Sh-F9(SIGKILL) and C-Sh-F11(SIGTERM) ..");
 
-        state = STATE_WAITINNG;
+        state = STATE_WAITING;
 
         if (o_flag == 0)
                 /* Start (S)XEmacs */



-- 
lg

<Prev in Thread] Current Thread [Next in Thread>