Newsgroups: comp.sys.apple2.gno Path: news.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!usc!elroy.jpl.nasa.gov!ncar!csn!col.hp.com!srgenprp!news.dtc.hp.com!hpscit.sc.hp.com!cupnews0.cup.hp.com!tribby From: tribby@cup.hp.com (Dave Tribby) Subject: Re: using signals Sender: news@cupnews0.cup.hp.com (News Admin) Message-ID: Date: Tue, 19 Apr 1994 18:52:20 GMT Reply-To: tribby@cup.hp.com (Dave Tribby) References: <2p165s$7he@news.tamu.edu> Nntp-Posting-Host: hpindhx.cup.hp.com Organization: HP Info Networks Div/Cupertino CA X-Newsreader: TIN [version 1.2 PL0.7] Lines: 69 Jason Perez (j0p7771@tam2000.tamu.edu) wrote: > how does one use signals in gno? Here's some code from synthfile.c, version 1.5... .... #include #include .... #pragma databank 1 /*----------------------------------------------------------------------*/ /* ===== GNO Signal handler routine ===== */ /*----------------------------------------------------------------------*/ void SigHandler(int sig, int code) { switch (sig) { case SIGINT: /* User keyboard interrupt: Stop playing/printing current song */ if (playing) StopSong(); printing = FALSE; break; case SIGUSR1: /* User-defined signal 1: print name of current file on stderr */ if (current_file) fprintf(stderr, " SynthFile: %s\n", current_file); break; case SIGHUP: case SIGTERM: /* Kill or hang-up: Stop playing, clean up, and terminate */ if (playing) StopSong(); if (play) { MSShutDown(); SoundShutDown(); DisposeHandle(sound_zero_page); } exit(1); } } #pragma databank 0 .... fprintf(stderr,"SynthFile handles the following GNO signals:\n"); fprintf(stderr, " kill -1 or kill -15: shutdown tools and terminate program\n"); fprintf(stderr, " kill -2 or interrupt key (^C): stop playing/printing a sequence file\n"); fprintf(stderr, " kill -30: print name of current file on standard error\n"); } .... /* Install the GNO signal handlers */ signal(SIGINT, SigHandler); signal(SIGTERM, SigHandler); signal(SIGHUP, SigHandler); signal(SIGUSR1, SigHandler); .... Hope this makes sense to you! -- Dave Tribby (tribby@cup.hp.com)