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