r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / guicast / bcsignals.C
blobb1f5e41e566236ab1c5085b9b59abc4db76f2582
1 #include "bcsignals.h"
2 #include "mutex.h"
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 BC_Signals* BC_Signals::signals_object = 0;
9 static char* signal_titles[] =
11 "NULL",
12 "SIGHUP",
13 "SIGINT",
14 "SIGQUIT",
15 "SIGILL",
16 "SIGTRAP",
17 "SIGABRT",
18 "SIGBUS",
19 "SIGFPE",
20 "SIGKILL",
21 "SIGUSR1",
22 "SIGSEGV",
23 "SIGUSR2",
24 "SIGPIPE",
25 "SIGALRM",
26 "SIGTERM"
29 BC_Signals::BC_Signals()
31         BC_Signals::signals_object = this;
32         lock = new Mutex;
33         signal(SIGHUP, signal_entry);
34         signal(SIGINT, signal_entry);
35         signal(SIGQUIT, signal_entry);
36         signal(SIGKILL, signal_entry);
37         signal(SIGSEGV, signal_entry);
38         signal(SIGTERM, signal_entry);
39         execution_table.set_array_delete();
43 void BC_Signals::signal_entry(int signum)
45         signals_object->lock->lock();
46         printf("BC_Signals::signal_handler: got %s execution_table.total=%d\n", 
47                 signal_titles[signum],
48                 signals_object->execution_table.total);
49         if(signals_object->execution_table.total)
50         {
51                 for(int i = 0; i < signals_object->execution_table.total; i++)
52                         printf("    %s\n", signals_object->execution_table.values[i]);
53         }
54         signals_object->signal_handler(signum);
55         signals_object->lock->unlock();
58 void BC_Signals::signal_handler(int signum)
60         exit(0);
63 char* BC_Signals::sig_to_str(int number)
65         return signal_titles[number];
68 void BC_Signals::new_function(char *name)
70 //printf("BC_Signals::new_function 1 %p\n", signals_object);
71         signals_object->lock->lock();
72 //printf("BC_Signals::new_function 1\n");
73         char *dup_name = new char[strlen(name)+1];
74         strcpy(dup_name, name);
75         signals_object->execution_table.append(dup_name);
76 //printf("BC_Signals::new_function 1\n");
77         signals_object->lock->unlock();
78 //printf("BC_Signals::new_function 10\n");
81 void BC_Signals::delete_function(char *name)
83         signals_object->lock->lock();
84         for(int i = 0; i < signals_object->execution_table.total; i++)
85         {
86                 if(!strcmp(signals_object->execution_table.values[i], name)) 
87                 {
88                         signals_object->execution_table.remove_object_number(i);
89                         break;
90                 }
91         }
92         signals_object->lock->unlock();