replacing sighold/sigrelse with sigprocmask in AIX/Unix/Solaris/Linux

some OS versions doesn't support sighold/sigrelse and makes si_pid and si_uid value '0' instead of sender/parent id.

We achive getting sender pid using sigprocmask call.

replace sighold and sigrelse with sigprocmask in following way.

  
    struct sigaction sigusr2_act;
    sigset_t nset, oset;
    

    sigemptyset( &sigusr2_act.sa_mask );
    sigusr2_act.sa_flags = 0;
    sigusr2_act.sa_handler = catcher;
    sigaction( SIGUSR2, &sigusr2_act, NULL );

    sigemptyset( &nset );
    sigaddset( &nset, SIGUSR2 );
    sigprocmask( SIG_BLOCK, &nset, &oset);
    printf( "SIUSR2 signal unblocked at here\n");
    CRITICAL CODE
    
    sigprocmask( SIG_SETMASK, &oset, NULL );
    printf( "SIUSR2 signal unblocked at here\n");

No comments :

Post a Comment