X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fraise.c;h=7f32b091ad4de5c8bf59f9f17bd75bc9a6def084;hb=39cedf6f427350ac47118d231c05a7b73b609f89;hp=3064889be810f6032fea4e245495c0e70224c4fc;hpb=57fdfd3f8ec62b105c53bcdf6f127c35c7fe7391;p=gnulib.git diff --git a/lib/raise.c b/lib/raise.c index 3064889be..7f32b091a 100644 --- a/lib/raise.c +++ b/lib/raise.c @@ -1,6 +1,6 @@ /* Provide a non-threads replacement for the POSIX raise function. - Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,16 +15,65 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* written by Jim Meyering */ +/* written by Jim Meyering and Bruno Haible */ #include -#include +/* Specification. */ #include -#include + +#if HAVE_RAISE +/* Native Windows platform. */ + +# include + +# include "msvc-inval.h" + +# undef raise + +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static inline int +raise_nothrow (int sig) +{ + int result; + + TRY_MSVC_INVAL + { + result = raise (sig); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EINVAL; + } + DONE_MSVC_INVAL; + + return result; +} +# else +# define raise_nothrow raise +# endif + +#else +/* An old Unix platform. */ + +# include + +# define rpl_raise raise + +#endif int -raise (int sig) +rpl_raise (int sig) { +#if GNULIB_defined_signal_blocking && GNULIB_defined_SIGPIPE + if (sig == SIGPIPE) + return _gl_raise_SIGPIPE (); +#endif + +#if HAVE_RAISE + return raise_nothrow (sig); +#else return kill (getpid (), sig); +#endif }