On Mon, Jan 11, 2010 at 05:22:56PM +0100, Cyril Hrubis wrote:
> 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)').
Naufel,
You might like to address the comments by Cyril. For named pipes you can
see man mkfifo in bash or open in c where you can specify the file as a
pipe or FIFO. A busy wait like you implemented is not a good practice.
Repost your patches with the comments addressed.

> 
> -- 
> 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

-- 
Regards
Sudhir Kumar
Linux Technology Center
IBM, India.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to