9.3 sig2str, str2sig—Translate between signal number and name

Synopsis

#include <signal.h>
int sig2str(int signum, char *str);

int str2sig(const char *restrict str, int *restrict pnum);

Description
The sig2str function translates the signal number specified by signum to a signal name and stores this string in the location specified by str. The application must ensure that str points to a location that can store the string including the terminating null byte. The symbolic constant SIG2STR_MAX defined in ‘signal.h’ gives the maximum number of bytes required.

The str2sig function translates the signal name in the string pointed to by str to a signal number and stores this value in the location specified by pnum.


Returns
sig2str returns 0 if signum> is a valid, supported signal number. Otherwise, it returns -1.

str2sig returns 0 if it stores a value in the location pointed to by pnum. Otherwise it returns -1.