1*38fd1498Szrj /* Execute a program and wait for a result.
2*38fd1498Szrj Copyright (C) 2005-2018 Free Software Foundation, Inc.
3*38fd1498Szrj
4*38fd1498Szrj This file is part of the libiberty library.
5*38fd1498Szrj Libiberty is free software; you can redistribute it and/or
6*38fd1498Szrj modify it under the terms of the GNU Library General Public
7*38fd1498Szrj License as published by the Free Software Foundation; either
8*38fd1498Szrj version 2 of the License, or (at your option) any later version.
9*38fd1498Szrj
10*38fd1498Szrj Libiberty is distributed in the hope that it will be useful,
11*38fd1498Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of
12*38fd1498Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13*38fd1498Szrj Library General Public License for more details.
14*38fd1498Szrj
15*38fd1498Szrj You should have received a copy of the GNU Library General Public
16*38fd1498Szrj License along with libiberty; see the file COPYING.LIB. If not,
17*38fd1498Szrj write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18*38fd1498Szrj Boston, MA 02110-1301, USA. */
19*38fd1498Szrj
20*38fd1498Szrj #include "config.h"
21*38fd1498Szrj #include "libiberty.h"
22*38fd1498Szrj
23*38fd1498Szrj const char *
pex_one(int flags,const char * executable,char * const * argv,const char * pname,const char * outname,const char * errname,int * status,int * err)24*38fd1498Szrj pex_one (int flags, const char *executable, char * const *argv,
25*38fd1498Szrj const char *pname, const char *outname, const char *errname,
26*38fd1498Szrj int *status, int *err)
27*38fd1498Szrj {
28*38fd1498Szrj struct pex_obj *obj;
29*38fd1498Szrj const char *errmsg;
30*38fd1498Szrj
31*38fd1498Szrj obj = pex_init (0, pname, NULL);
32*38fd1498Szrj errmsg = pex_run (obj, flags, executable, argv, outname, errname, err);
33*38fd1498Szrj if (errmsg == NULL)
34*38fd1498Szrj {
35*38fd1498Szrj if (!pex_get_status (obj, 1, status))
36*38fd1498Szrj {
37*38fd1498Szrj *err = 0;
38*38fd1498Szrj errmsg = "pex_get_status failed";
39*38fd1498Szrj }
40*38fd1498Szrj }
41*38fd1498Szrj pex_free (obj);
42*38fd1498Szrj return errmsg;
43*38fd1498Szrj }
44