How to send a signal to SDL application?

Hi all!

I have an embedded application which uses SDL for drawing and runs on
Linux frame buffer. I would like to send the application an signal
(SIGUSER1/SIGUSER2) and I would like that SDL would catch them. I have
done similar thing on Windows using SDL_SysWMmsg and WM messages, but
is it possible to do the same on Linux console?

Regards Simon

“Simon Posnjak” wrote:

I would like to send the application an signal
(SIGUSER1/SIGUSER2) and I would like that SDL would catch them.

huh? why should SDL handle your signals? and what do you want SDL to do
when it catches it? and how is SDL supposed to know what you want?

i guess you simply want to install a signal handler in your app and
catch the signal on your own.

man signal

in a nutshell:

#include <unistd.h>
#include <stdio.h>
#include <signal.h>

static int running = 1;

static void handler(int sig) {
printf(“got signal %i\n”, sig);
running = 0;
}

int main() {
signal(SIGUSR1, handler);
signal(SIGUSR2, handler);

while (running) usleep(10000);

return (0);

}

regards …
clemens

Why? Because I would like to handle the signal through SDL_event loop
via SDL_SysWMmsg. The way you recommend to do it is not “safe”.

Regards SimonOn 8/14/07, Clemens Kirchgatterer <clemens at 1541.org> wrote:

“Simon Posnjak” <@Simon_Posnjak> wrote:

I would like to send the application an signal
(SIGUSER1/SIGUSER2) and I would like that SDL would catch them.

huh? why should SDL handle your signals? and what do you want SDL to do
when it catches it? and how is SDL supposed to know what you want?

i guess you simply want to install a signal handler in your app and
catch the signal on your own.

man signal

in a nutshell:

#include <unistd.h>
#include <stdio.h>
#include <signal.h>

static int running = 1;

static void handler(int sig) {
printf(“got signal %i\n”, sig);
running = 0;
}

int main() {
signal(SIGUSR1, handler);
signal(SIGUSR2, handler);

    while (running) usleep(10000);

    return (0);

}

regards …
clemens


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

“Simon Posnjak” wrote:

Why? Because I would like to handle the signal through SDL_event loop

ah, ic.

via SDL_SysWMmsg. The way you recommend to do it is not “safe”.

i wouldn’t want sdl to mix up signals with SysWMmsgs, they are
completely unrelated. so i think your best bet is to just call
SDL_PumpEvent() in the signalhandler with whatever event you want.
the catch is to prbably get not portable code.

clemens

Hello !

If you only need a way to communicate between two
apps, the use of sockets might be a good idea.

CU