From b3e7aafff8dd3260b8e7a429d9bb6dc3f91a1850 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 1 May 2013 22:01:09 +0200 Subject: [PATCH] Add psignal(3). --- libc/Makefile | 1 + libc/psignal.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 libc/psignal.cpp diff --git a/libc/Makefile b/libc/Makefile index 46e97037..207fe962 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -290,6 +290,7 @@ poll.o \ popen.o \ ppoll.o \ print.o \ +psignal.o \ putc.o \ pwent.o \ raise.o \ diff --git a/libc/psignal.cpp b/libc/psignal.cpp new file mode 100644 index 00000000..d759a9fd --- /dev/null +++ b/libc/psignal.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2013. + + This file is part of the Sortix C Library. + + The Sortix C Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + The Sortix C Library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with the Sortix C Library. If not, see . + + psignal.cpp + Print signal error condition to stderr. + +*******************************************************************************/ + +#include +#include +#include + +extern "C" void psignal(int signum, const char* message) +{ + if ( message && message[0] ) + fprintf(stderr, "%s: ", message); + fprintf(stderr, strsignal(signum)); +}