Hi!

> /*
> sigusr1: allocate/free memory on receving SIGUSR1
> */
> void sigusr1(int num) {
>   mem_map();
>   flag_allocated = !flag_allocated;
> }
> 
> int main(int argc, char **argv) {
>   signal(SIGINT, sigint);
>   signal(SIGUSR1, sigusr1);
> 
>   process_options(argc, argv);
> 
>   while(!flag_exit)
>     sleep(1);
> 
>   return 0;
> }


You can't allocate memory from signal handler. There is a list of signal safe
functions in 'man 7 signal'. The correct solution for this is to create
something like named pipe and sleep in read() on it (instead of
'while(!flag_exit) sleep(1)').

-- 
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to