1184902Srwatson/*
2184902Srwatson * Copyright (C) 2003 David Xu<davidxu@freebsd.org>.
3189279Srwatson * All rights reserved.
4189279Srwatson *
5189279Srwatson * Redistribution and use in source and binary forms, with or without
6189279Srwatson * modification, are permitted provided that the following conditions
7189279Srwatson * are met:
8189279Srwatson * 1. Redistributions of source code must retain the above copyright
9189279Srwatson *    notice(s), this list of conditions and the following disclaimer as
10189279Srwatson *    the first lines of this file unmodified other than the possible
11189279Srwatson *    addition of one or more copyright notices.
12189279Srwatson * 2. Redistributions in binary form must reproduce the above copyright
13189279Srwatson *    notice(s), this list of conditions and the following disclaimer in
14189279Srwatson *    the documentation and/or other materials provided with the
15189279Srwatson *    distribution.
16189279Srwatson *
17189279Srwatson * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
18189279Srwatson * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19189279Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20189279Srwatson * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
21189279Srwatson * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22187214Srwatson * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23187214Srwatson * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24187214Srwatson * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25187214Srwatson * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26187214Srwatson * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27187214Srwatson * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28187214Srwatson *
29187214Srwatson * $FreeBSD$
30187214Srwatson */
31187214Srwatson
32187214Srwatson#include "namespace.h"
33187214Srwatson#include <errno.h>
34187214Srwatson#include <pthread.h>
35187214Srwatson#include "un-namespace.h"
36187214Srwatson#include "thr_private.h"
37187214Srwatson
38187214Srwatsonint	_raise(int sig);
39187214Srwatson
40187214Srwatson__weak_reference(_raise, raise);
41186647Srwatson
42186647Srwatsonint
43186647Srwatson_raise(int sig)
44186647Srwatson{
45186647Srwatson	int ret;
46186647Srwatson
47186647Srwatson	if (!_kse_isthreaded())
48186647Srwatson		ret = kill(getpid(), sig);
49186647Srwatson	else {
50186647Srwatson		ret = _pthread_kill(_pthread_self(), sig);
51186647Srwatson		if (ret != 0) {
52186647Srwatson			errno = ret;
53186647Srwatson			ret = -1;
54186647Srwatson		}
55186647Srwatson	}
56186647Srwatson	return (ret);
57186647Srwatson}
58186647Srwatson