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