thr_system.c revision 256281
1234285Sdim/*
2234285Sdim * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
3234285Sdim * All rights reserved.
4234285Sdim *
5234285Sdim * Redistribution and use in source and binary forms, with or without
6234285Sdim * modification, are permitted provided that the following conditions
7234285Sdim * are met:
8234285Sdim * 1. Redistributions of source code must retain the above copyright
9234285Sdim *    notice(s), this list of conditions and the following disclaimer as
10249423Sdim *    the first lines of this file unmodified other than the possible
11249423Sdim *    addition of one or more copyright notices.
12249423Sdim * 2. Redistributions in binary form must reproduce the above copyright
13234285Sdim *    notice(s), this list of conditions and the following disclaimer in
14234285Sdim *    the documentation and/or other materials provided with the
15234285Sdim *    distribution.
16234285Sdim *
17234285Sdim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
18234285Sdim * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19234285Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20234285Sdim * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
21234285Sdim * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22234285Sdim * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23249423Sdim * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24249423Sdim * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25249423Sdim * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26234285Sdim * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27234285Sdim * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28234285Sdim *
29251662Sdim * $FreeBSD: stable/10/lib/libkse/thread/thr_system.c 174689 2007-12-16 23:29:57Z deischen $
30251662Sdim */
31251662Sdim
32251662Sdim#include "namespace.h"
33251662Sdim#include <stdlib.h>
34234285Sdim#include <pthread.h>
35234285Sdim#include "un-namespace.h"
36234285Sdim#include "thr_private.h"
37234285Sdim
38234285Sdimint	_system(const char *string);
39251662Sdim
40234285Sdimextern int __system(const char *);
41234285Sdim
42234285Sdim__weak_reference(_system, system);
43234285Sdim
44234285Sdimint
45234285Sdim_system(const char *string)
46251662Sdim{
47251662Sdim	struct pthread *curthread = _get_curthread();
48251662Sdim	int	ret;
49251662Sdim
50234285Sdim	_thr_cancel_enter(curthread);
51234285Sdim	ret = __system(string);
52234285Sdim	_thr_cancel_leave(curthread, 1);
53234285Sdim
54234285Sdim	return ret;
55234285Sdim}
56234285Sdim