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, 16 Jan 2019 09:32:50 +0100

Dear Nicola,
I do not understand the patch. You need to send *two* kill (first ::killpg()
and then killI()) to the same pid? or is putting the pid in the local
variable that makes things works?

Is not clear to me what is going on.

Best
Max



> On 16. Jan 2019, at 01:21, Nicola Mingotti <address@hidden> wrote:
>
>
> I was able to fix it !
>
> After patching, my Ruby plugin and Max test plugin both work.
>
> Without the patch my plugin does not get the SIGINT and Max plugin
> does not reset the counter.
>
> The working patch for TeXmacs 1.99.4 (tested valid for FreeBSD 11.2) is :
>
> -----------------------
> --- src/Plugins/Qt/qt_pipe_link.cpp.orig 2019-01-15 23:10:27 UTC
> +++ src/Plugins/Qt/qt_pipe_link.cpp
> @@ -9,6 +9,9 @@
> * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
>
> ******************************************************************************/
>
> +// for my debug
> +#include<iostream>
> +
> #include "basic.hpp"
>
> #if defined (QTTEXMACS) && (defined (__MINGW__) || defined (__MINGW32__)
> || defined (QTPIPES))
> @@ -144,8 +147,15 @@ qt_pipe_link_rep::interrupt () {
> if (!alive) return;
> #if defined(__MINGW__) || defined(__MINGW32__)
> // Not implemented
> -#else
> +#else
> ::killpg(PipeLink.pid (), SIGINT);
> +
> + // for some reason the prevoius "kill" kills
> + // (-1)*myPid.
> + int myPid = PipeLink.pid();
> + cout << "DBG> signal SIGINT on pid: " << myPid << "\n";
> + kill(myPid, SIGINT);
> +
> #endif
> }
> -----------------------
>
> bye
> Nicola
>
>
>
>
> On 1/15/19 12:35 PM, Nicola Mingotti wrote:
>>
>> 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