Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Library Function – sigemptyset()

C Library Function - sigemptyset()

C Standard Library - <signal.h> C Standard Library -

sigpending The function is a function in the C standard library, used to get the pending (unhandled) signal set of the current process. A pending signal is one that has been blocked but not yet handled. This function is defined in header.

Syntax

int sigemptyset(sigset_t *set);

Parameters

Return Value

Example

The following is an example of using sigemptyset Example program demonstrating the function initializing a signal set. The program initializes a signal set and checks whether it contains a specific signal.

Example

#include

#include

int

main

(

)

{

    sigset_t set

;

   

// initialize the signal set to empty

   

if

(

sigemptyset

(

&

set

)

==

1

)

{

       

perror

(

"sigemptyset"

)

;

       

return

1

;

   

}

   

// check whether the signal set contains SIGINT

   

if

(

sigismember

(

&

set

,

SIGINT

)

)

{

       

printf

(

"SIGINT is in the set\n"

)

;

   

}

else

{

       

printf

(

"SIGINT is not in the set\n"

)

;

   

}

   

return

0

;

}

After compiling and running the program, the output will be:



SIGINT is not in the set

The program first blocks SIGINT signal, then sends the signal, and uses sigpending Checks SIGINT whether it is in the pending signal set. Finally, the program restores the original signal mask, and catches the SIGINT signal and executes the signal handler.

Parsing

Notes

C Standard Library - <signal.h> C Standard Library -