From owner-freebsd-questions Sat Jan 15 19:43:22 2000 Delivered-To: freebsd-questions@freebsd.org Received: from alpha.pit.adelphia.net (alpha.pit.adelphia.net [24.48.44.2]) by hub.freebsd.org (Postfix) with ESMTP id C11D2151A2 for ; Sat, 15 Jan 2000 19:43:18 -0800 (PST) (envelope-from evstiounin@adelphia.net) Received: from evstiouninadelphia ([24.48.53.248]) by alpha.pit.adelphia.net (8.9.2/8.9.2) with SMTP id WAA18819; Sat, 15 Jan 2000 22:43:08 -0500 (EST) Message-ID: <00cf01bf5fd4$34f2dc20$f8353018@evstiouninadelphia.net.pit.adelphia.net> From: "Mikhail Evstiounin" To: "Mikhail Evstiounin" , Subject: Re: Volatile variables Date: Sat, 15 Jan 2000 22:45:58 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >int allocated = 0; >char *mem = NULL; > > >void Sigusr1Handler( int siganl ) >{ > if ( allocateded ) > { > sleep( 60 ); // just for fun > mem[ 2 ] = 'F'; > ... > > } >} > >void Sigusr2Handler( int siganl ) >{ > if ( allocated ) > { > free( mem ); > mem = NULL; > opened = 0; > } >} > >int main( int argc, char* argv[] ) >{ > mem = ( char* )malloc( 20 ); > opend = 1; > ... > > return 0; >} Sorry, shoud be int allocated = 0; char *mem = NULL; void Sigusr1Handler( int siganl ) { if ( allocateded ) { sleep( 60 ); // just for fun mem[ 2 ] = 'F'; ... } } void Sigusr2Handler( int siganl ) { if ( allocated ) { free( mem ); mem = NULL; allocated = 0; } } int main( int argc, char* argv[] ) { mem = ( char* )malloc( 20 ); opend = 1; signal( SIGUSR1, Sigusr1Handler ); signal( SIGUSR2, Sigusr2Handler ); ... return 0; } compile, run and send 2 signals to a program -SIGUSR1 and SIGUSR2. Actually, I am not sure if SIGUSR1 doesn't mask SIGUSR2, but you can always choose two, when doesn't mask another. And see what is going to happen if you use or do not use vilotile. > > > > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message