pex-one.c revision 302408
12061Sjkh/* Execute a program and wait for a result. 250479Speter Copyright (C) 2005 Free Software Foundation, Inc. 32061Sjkh 438666SjbThis file is part of the libiberty library. 532427SjbLibiberty is free software; you can redistribute it and/or 6103985Sphkmodify it under the terms of the GNU Library General Public 7103985SphkLicense as published by the Free Software Foundation; either 838666Sjbversion 2 of the License, or (at your option) any later version. 938666Sjb 1038666SjbLibiberty is distributed in the hope that it will be useful, 1138666Sjbbut WITHOUT ANY WARRANTY; without even the implied warranty of 1264049SalexMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1364049SalexLibrary General Public License for more details. 1466071Smarkm 1573504SobrienYou should have received a copy of the GNU Library General Public 1638666SjbLicense along with libiberty; see the file COPYING.LIB. If not, 1744918Sjkhwrite to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 1838666SjbBoston, MA 02110-1301, USA. */ 1938666Sjb 2038666Sjb#include "config.h" 2138666Sjb#include "libiberty.h" 2238666Sjb 2338666Sjbconst char * 2438666Sjbpex_one (int flags, const char *executable, char * const *argv, 2538978Sjb const char *pname, const char *outname, const char *errname, 2638978Sjb int *status, int *err) 2732427Sjb{ 2838666Sjb struct pex_obj *obj; 2938666Sjb const char *errmsg; 3038666Sjb 3138666Sjb obj = pex_init (0, pname, NULL); 3238666Sjb errmsg = pex_run (obj, flags, executable, argv, outname, errname, err); 3338666Sjb if (errmsg == NULL) 3417308Speter { 3591606Skeramida if (!pex_get_status (obj, 1, status)) 3619175Sbde { 3796205Sjwd *err = 0; 3896205Sjwd errmsg = "pex_get_status failed"; 3938042Sbde } 4096205Sjwd } 4196205Sjwd pex_free (obj); 4238042Sbde return errmsg; 4396205Sjwd} 4496205Sjwd