1. When Linux processes command-line programs, the input parameters can be processed using the GET_OPT library function, which facilitates the production of command-line tools.
2. When the program needs to stop waiting for the signal to end, the usual practice is to use a while (true) loop, so that the program's CPU consumes very high, using the Sigpause function.
sigpause temporarily replaces the signal mask of the calling process with the mask given by mask and then suspends the Process until delivery of a signal whose action is to invoke a signal handler or to terminate a process.
If the signal terminates the process, then sigsuspend() does not return. If the signal is caught, then sigsuspend() returns after the signal handler returns, and the signal mask is Resto
sigpause needs to pass in a mask when used, When the program executes here, Sigpause temporarily replaces the mask of the current process with the incoming mask, and blocks the use of the CPU until a signal outside the mask arrives. normally, sigsuspend () is used in conjunction with < Strong>sigprocmask (2) in order to prevent delivery of a signal during the execution of a critical code section. The caller first blocks the signals with Sigprocmask (2). When the critical code had completed, the caller then waits for the signals by CALLING&NBSP; Sigsuspend () With the signal mask is returned by Sigprocmask (2) (in the oldset argument).
Sigsuspend (2) -waits for any signal. It takes a signal mask of signals that is atomically unblocked,
The sigsuspend() function is the modern analogue of the old pause() function.
Major change:two code blocks reversed.
It allows to send your thread to sleep until one of its selected signals occurs. If you want it to sleep until Sigrtmin+1 arrives, you use:
sigfillset(&mask);sigdelset(&mask, SIGRTMIN+1);sigsuspend(&mask);
This blocks every signal except sigrtmin+1.
If you want to sleep until a signal other than sigrtmin+1 arrives, you use:
sigemptyset(&mask);sigaddset(&mask, SIGRTMIN+1);sigsuspend(&mask);
This blocks is only sigrtmin+1.
Linux get_opt sigpause