mailing-list for TeXmacs Users

Text archives Help


Re: [TeXmacs] Is SIGINT sent to plugins ?


Chronological Thread 
  • From: Nicola Mingotti <address@hidden>
  • To: Massimiliano Gubinelli <address@hidden>
  • Cc: texmacs-users <address@hidden>, Nicola Mingotti <address@hidden>
  • Subject: Re: [TeXmacs] Is SIGINT sent to plugins ?
  • Date: Tue, 15 Jan 2019 12:35:02 -0800


Please don't put much wait on what i wrote,
I may have made a mistake in recompiling the FreeBSD port
which messed all the thing up.

The negative PID is there, but my changes to the code may
have not be taken at all in subsequent tests ... i am checking and
trying to understand.

I will let you know ASAP.

sorry
bye
n.

On 1/14/19 5:39 PM, Nicola Mingotti wrote:

Hello Max,

I have had finally time to do further experiments.

I tried your test plugin, in my system (FreeBSD 11.2, Texmacs v. 1.99.4 from ports) it works
with and without your patch. Quite misteriously i must say.

My plugin instead keeps on not working and not receiving SIGINT.

I start to doubt i have a bug in my code somewhere, but it is wired,
if I run my plugin on the console it behaves well on Ctrl-C !

I have discovered something that is interesting.

If I run:
$> truss ./texmacs -x '(make-session "ruby" "default")' 2>&1 | grep '^kill'

I get this stuff :
kill(-59846,SIGINT)   # ERR3, no such process

... i have never seen a negative pid in life.

I tried to change TeXmacs code you modified many times, but it seems the damn negative
pid not going to change, whatever i do, eg :
---
  Q_PID pid = PipeLink.pid ();
  int ret =  ::kill(-pid, SIGINT);
---

A different but still negative pid appears to be sent to your plugin,
but, for some reason, your plugin gets the SIGINT.

I am extremely puzzled,
do you have any idea ?

bye
n.


On 12/12/18 8:56 AM, Massimiliano Gubinelli wrote:
Hi again,

On 11. Dec 2018, at 20:11, Nicola Mingotti <address@hidden> wrote:

Hi again,

I am puzzled, I am trying to get the SIGINT from my plugin
but it seems to me TeXmacs is not sending that signal.


Seems there is a bug with the signals. I attach a patch and a test program (which has to be installed as a plugin).

I will commit a patch in svn.

Best
Max


-----------------------------------------------------------------------
The patch
-8<---------------------------------------------------------------------
Index: src/Plugins/Qt/qt_pipe_link.cpp
===================================================================
--- src/Plugins/Qt/qt_pipe_link.cpp    (revision 11316)
+++ src/Plugins/Qt/qt_pipe_link.cpp    (working copy)
@@ -148,7 +148,11 @@
    qt_error << "SIGINT not implemented on Windows\n";
  #else
    Q_PID pid = PipeLink.pid ();
-  int ret =  ::killpg (pid, SIGINT);
+
+  // REMARK: previously there were here below a call to ::killpg which does not seems to work on MacOS
+  // I (mgubi) replaced it with ::kill which does the job. But I do not undestand the difference.
+
+  int ret =  ::kill (pid, SIGINT);
    if (ret == -1) {
      qt_error << "Interrupt not successful, pid: " << pid << " return code: " << errno << "\n";
    }
-8<--------------------------------------------------------------------
The test program
-8<--------------------------------------------------------------------
#include <iostream>
#include <unistd.h>
#include <csignal>

using namespace std;

#define DATA_BEGIN   ((char) 2)
#define DATA_END     ((char) 5)
#define DATA_ESCAPE  ((char) 27)

bool trig = true;
int cc = 0;

void signalHandler( int signum ) {
     trig = false;
}

int
main () {
   cout << DATA_BEGIN << "verbatim:";
   cout << "STARTING\n";
   cout << DATA_END;
   cout.flush ();

   // register signal SIGINT and signal handler
   signal(SIGINT, signalHandler);

     while (1) {
         char buffer[100];
         cin.getline (buffer, 100, '\n');
         cout << DATA_BEGIN << "verbatim:";
         cout << "Input: " << buffer << "\n";
         cout.flush ();

         while (trig) {
             cout << "Going to sleep.... (" << cc ++ << ")\n";
             cout.flush ();
             sleep (1);
         }
         cout << DATA_END;
         cout.flush ();
         trig = true; cc = 0;
     }
   return 0;
}
-8<--------------------------------------------------------------------


I am using TeXmacs version 1.99.4 in FreeBSD.

Do you know of any plugin who is actually managing SIGINT correctly ?
I tried Python (not working, not implemented IFACSay), Scheme (no button), Maxima (not working).

I test the SIGINT is not working in this way, for Python i can actually
check there is not signal receiver in the code, so, not a TeXmacs problem, but the method I use in general is:

1] Run a sleep command, 10 seconds
2] Press the STOP button in TeXmacs
3] Run a simple arithmentic command e.g. 1+1

=== Pyjhon ===
import time
timp.sleep(10)
PRESS QUIT
1+1
HANGS till end of sleep
=============

==== Maxima ====
:lisp (sleep 10)
PRESS QUIT
1
HANGS till end of sleep
================

Maybe also Maxima plugin is not catching the SIGINT...
In my plugin managed to receive the signal but I don't see it coming when i press the STOP button.

Do you know something about it ?

bye
Nicola








Archive powered by MHonArc 2.6.19.

Top of page