ncurses a SIGWINCH

Karel Zak zakkr na zf.jcu.cz
Pátek Listopad 10 12:19:57 CET 2000


On Fri, 10 Nov 2000, Petr Nehasil wrote:

> Karel Zak wrote:
> > 
> > On Fri, 10 Nov 2000, Mila Kuchta wrote:
>  
> >  Obecne v C, prosim nedelejte v handlerech signalu pokud mozno vubec nic,
> > zvlaste pak pokud existuji jina zretelne mene "partyzanska" reseni.
> > 
> >  Obavam se, ze cmarani na screen a zmeny nastaveni prostredi v nemz ncurses
> > zije neni zase tak moc jemna zalezitost, aby se delala v handleru signalu.
> > 
> >                                                 Karel
> 
> Mohl bych se zeptat co se da a neda v handleru delat?
> 
> Naposledy jsem napsal programek, ktery v handleru odesilal
> data ze sdilene pameti pres TCPIP dal.
> Byl to takovy pokus o obsluhu prototypu grabovaci karty.
> Driver od karty poslal SIGUSR2, coz znamenalo, ze ve sdilene
> pameti je hotovy pulsnimek.
> 
> Je to prasarna? Pokud ano, vite jak to udelat lepe ( a radostneji ) ?

 IMHO jste drsnak...

 Ten samotny program na necem ceka, nebo neco dela. Proc ho tedy neuspat na
select() a po urcite casove dobe (mozno i < 1sec) testovat nejakou pormennou, 
pokud bude TRUE tak by vlastni program vykonal pozadovanou praci a zase
usnul. Vlastni handler pak bude osahovat jen nastaveni promenne na TRUE.

 Jinak:

http://docs.linux.cz/programming/c/glibc-manual-0.02/library_21.html#SEC357

(precist! - je tam vsechno)


 Signal Handling and Nonreentrant Functions

   Handler functions usually don't do very much. The best practice is to write 
a handler that does nothing but set an external variable that the program checks
regularly, and leave all serious work to the program. This is best because the 
handler can be called at asynchronously, at unpredictable times--perhaps in the 
middle of a system call, or even between the beginning and the end of a C operator 
that requires multiple instructions. The data structures being manipulated might 
therefore be in an inconsistent state when the handler function is invoked. Even 
copying one int variable into another can take two instructions on most machines.

   This means you have to be very careful about what you do in a signal
handler.

					Karel



Další informace o konferenci Linux