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