source: trunk/instant_messenger/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/signal.c @ 151

Revision 151, 683 bytes checked in by niltonneto, 16 years ago (diff)

Commit da nova versão do módulo, usando agente em C.
Vide Página do módulo do Trac:
http://www.expressolivre.org/dev/wiki/messenger

A versão anterior encontra-se na subpasta bkp (32/64).

Line 
1#include <signal.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5/* This flag controls termination of the main loop.  */
6volatile sig_atomic_t keep_going = 1;
7
8/* The signal handler just clears the flag and re-enables itself.  */
9        void
10catch_alarm (int sig)
11{
12        keep_going = 0;
13        puts("ALARM");
14        signal (sig, catch_alarm);
15}
16
17        void
18do_stuff (void)
19{
20        puts ("Doing stuff while waiting for alarm....");
21}
22
23        int
24main (void)
25{
26        /* Establish a handler for SIGALRM signals.  */
27        signal (SIGALRM, catch_alarm);
28
29        /* Set an alarm to go off in a little while.  */
30        alarm (2);
31
32        /* Check the flag once in a while to see when to quit.  */
33        while (keep_going)
34                do_stuff ();
35
36        return EXIT_SUCCESS;
37}
Note: See TracBrowser for help on using the repository browser.