[BACK]Return to signalname.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / gen

File: [cvs.NetBSD.org] / src / lib / libc / gen / signalname.c (download)

Revision 1.1, Tue May 9 11:14:16 2017 UTC (6 years, 11 months ago) by kre
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, matt-nb8-mediatek-base, matt-nb8-mediatek, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, HEAD
Branch point for: prg-localcount2



Add the new signalname/signalnext/signalnumber interface to libc.

This as discussed on current-users in the thread
entitled:
  Proposal: new libc/libutil functions to map SIGXXXX <-> "XXXX"
that can be found (starting at):
  http://mail-index.netbsd.org/current-users/2017/04/28/msg031600.html

These functions provide the mechanism to enable applications
to divorce themselves from internal details of the signal
implementation.

Libc minor bumped, prototypes in <signal.h>, sets lists updated (and sorted).

One and all: feel free to improve the sources & man page (etc), but
please do not change the function signatures without discussion.

/* $NetBSD: signalname.c,v 1.1 2017/05/09 11:14:16 kre Exp $ */

/*
 * Software available to all and sundry without limitations
 * but without warranty of fitness for any purpose whatever.
 *
 * Licensed for any use, including redistribution in source
 * and binary forms, with or without modifications, subject
 * the following agreement:
 *
 * Licensee agrees to indemnify licensor, and distributor, for
 * the full amount of any any claim made by the licensee against
 * the licensor or distributor, for any action that results from
 * any use or redistribution of this software, plus any costs
 * incurred by licensor or distributor resulting from that claim.
 *
 * This licence must be retained with the software.
 */

#include <sys/types.h>

#include <signal.h>
#include <string.h>

/*
 * signalname()
 *
 *	Converts the signal number "sig" to its
 *	signal name (without the "SIG" prefix).
 *
 * Returns:
 *	NULL on error (invalid signal number)
 *	otherwise the (abbreviated) signal name (no "SIG").
 */

const char *
signalname(int sig)
{

	if (sig <= 0 || sig >= NSIG)
		return NULL;

	return sys_signame[sig];
}