mailing-list for TeXmacs Users

Text archives Help


Re: [TeXmacs] Is SIGINT sent to plugins ?


Chronological Thread 
  • From: Massimiliano Gubinelli <address@hidden>
  • To: Nicola Mingotti <address@hidden>
  • Cc: texmacs-users <address@hidden>
  • Subject: Re: [TeXmacs] Is SIGINT sent to plugins ?
  • Date: Wed, 12 Dec 2018 16:56:44 +0000

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