Definition:
ubuntu@ip-172-31-23-227:~$ less /usr/include/signal.h
......
/* Names of the signals. This variable exists only for compatibility.
Use `strsignal' instead (see <string.h>). */
extern const char *const _sys_siglist[_NSIG];
extern const char *const sys_siglist[_NSIG];
......
Example:
siglist.c:
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<signal.h>
int main(int argc, char* argv[])
{
printf("SIGCONT: %s\n", sys_siglist[SIGCONT]);
printf("SIGCHLD: %s\n", sys_siglist[SIGCHLD]);
exit(0);
}
shell:
ubuntu@ip-172-31-23-227:~$ ./siglist.out
SIGCONT: Continued
SIGCHLD: Child exited
2. psignal
Definition:
ubuntu@ip-172-31-23-227:~$ less /usr/include/signal.h
......
/* Print a message describing the meaning of the given signal number. */
extern void psignal (int __sig, const char *__s);
......
Example:
psignal.c:
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<signal.h>
int main(int argc, char* argv[])
{
psignal(SIGCONT, "SIGCONT:");
psignal(SIGCHLD, "SIGCHLD:");
exit(0);
}
shell:
ubuntu@ip-172-31-23-227:~$ ./psignal.out
SIGCONT:: Continued
SIGCHLD:: Child exited
3. strsignal
System Definition:
ubuntu@ip-172-31-23-227:~$ less /usr/include/string.h
......
/* Return a string describing the meaning of the signal number in SIG. */
extern char *strsignal (int __sig) __THROW;
......
Example:
strsig.c:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<signal.h>
int main(int argc, char* argv[])
{
char *p = strsignal(SIGCONT);
printf("SIGCONT: %s\n", p);
p = strsignal(SIGCHLD);
printf("SIGCHLD: %s\n", p);
exit(0);
}
shell:
ubuntu@ip-172-31-23-227:~$ ./strsig.out
SIGCONT: Continued
SIGCHLD: Child exited
4. sig2str, str2sig
Definition:
No comments:
Post a Comment