Passing parameters to signal()?

Ivan Covdy ivan at dbaccess.com
Wed Sep 19 04:13:25 AEST 1990


I received a lot of mail with the same question:
Why I need to pass parameters to Action() when calling signal( SIGN, Action).
In a simplified form, my problem looks like this.

There is WaitSignal() function which should catch, let us say, SIGN1
and SIGN2, from another process, and, dependent upon the signal's type,
change the contains of the shared buffer (pointer to this buffer,
pSharedMem, is passed to WaitSignal):

WaitSignal( char *pSharedMem )
{
    ...
    signal( SIGN1, Action );
    signal( SIGN2, Action );
    ...
}

void Action( int Signal )
{
   ...
   switch ( Signal )
   {
       case SIGN1: *pSharedMem = 'A'; break;
       case SIGN2: *pSharedMem = 'B'; break;
       ...
   }
   ...
}

My limitation is that I cannot have external/global variables for
functions Action() and WaitSignal(), because these functions can be
linked to several mains() by different ways on different systems
(...well, common code can be called from multiple tasks).

Hence, there is a problem to access pSharedMem inside of Action()
and/or Signal inside of WaitSignal().

Thank you for your help.
-- 
Ivan Covdy                        INTERNET: ivan at dbaccess.com
c/o DB/Access Inc.                UUCP: {uunet,mips}!troi!ivan
2900 Gordon Avenue, Suite 101     FAX: (408) 735-0328
Santa Clara, CA 95051             TEL: (408) 735-7545



More information about the Comp.unix.internals mailing list