Send signal to application [message #213050] |
Sun, 30 March 2008 08:58  |
Eclipse User |
|
|
|
Originally posted by: ragatol.netsite.com.br
Hi,
Is there any way to send a signal to the application running inside Eclipse, eg.
SIGINT?
Thanks in advance,
Rafael.
|
|
|
|
Re: Send signal to application [message #213087 is a reply to message #213082] |
Sun, 30 March 2008 15:47   |
Eclipse User |
|
|
|
Originally posted by: ragatol.netsite.com.br
Hi Enrico,
This method of sending signals supports MinGW's gdb? I tried what you said: gdb
prints that it's received the signal, but my program doesn't seem to receive it.
It's just a small test program:
// testsig.cpp ---------------------------------------------------------
#include <cstdio>
#include <signal.h>
static bool loop;
static void sigfunc(int);
int main(int argc, char **argv) {
loop = true;
if (signal(SIGINT,sigusr) == SIG_ERR) {
printf("Could not setup signal handler for SIGINT!\n");
return -1;
}
printf("Waiting for SIGINT. Press Ctrl+C to exit.\n");
while (loop);
return 0;
}
static void sigfunc(int signo) {
if (signo == SIGINT) {
printf("SIGINT received!\n");
loop = false;
}
}
//---------------------------------------------------------- --------------
It works perfectly when executed in a console, but inside Eclipse gdb doesn't
send the signal to it when debugging. I get the following messages:
Quit (expect signal SIGINT when the program is resumed)
signal SIGINT
Program received signal SIGINT, Interrupt.
0x7c87534d in KERNEL32!GetConsoleCharType () from D:\WINDOWS\system32\kernel32.dll
[Switching to thread 3284.0xcac]
but my program doesn't return, I have to kill the process. I tried different
combinations of pass and suspend options, without success.
Any idea of why is that happening?
Thanks,
Rafael.
Enrico Ehrich escreveu:
> Hi Rafael,
>
> In the Debug perspective you can open a view called "Signals"
> (Window/Show View/Signals" or Left-Bottom Icon).
>
> You will get a list of all supported signals. Right click and "Resume
> with Signal" will give you the result you need.
>
> Enrico
>
> Rafael Fernandes wrote:
>> Hi,
>>
>> Is there any way to send a signal to the application running inside
>> Eclipse, eg. SIGINT?
>>
>> Thanks in advance,
>>
>> Rafael.
|
|
|
|
Re: Send signal to application [message #213122 is a reply to message #213093] |
Mon, 31 March 2008 10:02  |
Eclipse User |
|
|
|
Originally posted by: ragatol.netsite.com.br
DimDim escreveu:
> Your problem is that gdb pauses when the signal is recieved.
>
> You need to click somewhere to make it resume it's execution (when you
> run outside eclipse with a gdb you type "contiune" (I think "c" is
> enought to make it continue) in the gdb terminal to make it continue
>
I know that. :/
There's what I'm (and Eclipse is) trying to do:
E:\Documentos\cpp\testescpp>gdb Debug\testsig.exe
GNU gdb 6.7.50.20071127
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) handle SIGINT pass
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) y
Signal Stop Print Pass to program Description
SIGINT Yes Yes Yes Interrupt
(gdb) run
Starting program: E:\Documentos\cpp\testescpp/Debug\testsig.exe
Waiting for SIGINT. Press Ctrl+C to exit.
(Ctrl+C pressed...)
Program received signal SIGINT, Interrupt.
[Switching to thread 3840.0xf08]
0x7c87534d in KERNEL32!GetConsoleCharType (Quit (expect signal SIGINT when the p
rogram is resumed)
(gdb) signal SIGINT
Continuing with signal SIGINT.
(Ctrl+C pressed...)
Program received signal SIGINT, Interrupt.
[Switching to thread 3840.0xf08]
0x7c87534d in KERNEL32!GetConsoleCharType (Quit (expect signal SIGINT when the p
rogram is resumed)
(gdb) continue
Continuing.
(Ctrl+C pressed...)
[Switching to thread 3840.0xf1c]
0x7c810659 in KERNEL32!CreateThread () from D:\WINDOWS\system32\kernel32.dll
Quit (expect signal SIGINT when the program is resumed)
(gdb) info handle
Signal Stop Print Pass to program Description
SIGHUP Yes Yes Yes Hangup
SIGINT Yes Yes Yes Interrupt
[...]
(gdb) kill
Kill the program being debugged? (y or n) y
(gdb) quit
So, I just can't send SIGINT to the program. But I'm no gdb expert, maybe I'm
doing something wrong.
|
|
|
Powered by
FUDForum. Page generated in 0.04067 seconds