1169695Skan/* Execute a program and wait for a result. 2169695Skan Copyright (C) 2005 Free Software Foundation, Inc. 3169695Skan 4169695SkanThis file is part of the libiberty library. 5169695SkanLibiberty is free software; you can redistribute it and/or 6169695Skanmodify it under the terms of the GNU Library General Public 7169695SkanLicense as published by the Free Software Foundation; either 8169695Skanversion 2 of the License, or (at your option) any later version. 9169695Skan 10169695SkanLibiberty is distributed in the hope that it will be useful, 11169695Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of 12169695SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13169695SkanLibrary General Public License for more details. 14169695Skan 15169695SkanYou should have received a copy of the GNU Library General Public 16169695SkanLicense along with libiberty; see the file COPYING.LIB. If not, 17169695Skanwrite to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 18169695SkanBoston, MA 02110-1301, USA. */ 19169695Skan 20169695Skan#include "config.h" 21169695Skan#include "libiberty.h" 22169695Skan 23169695Skanconst char * 24169695Skanpex_one (int flags, const char *executable, char * const *argv, 25169695Skan const char *pname, const char *outname, const char *errname, 26169695Skan int *status, int *err) 27169695Skan{ 28169695Skan struct pex_obj *obj; 29169695Skan const char *errmsg; 30169695Skan 31169695Skan obj = pex_init (0, pname, NULL); 32169695Skan errmsg = pex_run (obj, flags, executable, argv, outname, errname, err); 33169695Skan if (errmsg == NULL) 34169695Skan { 35169695Skan if (!pex_get_status (obj, 1, status)) 36169695Skan { 37169695Skan *err = 0; 38169695Skan errmsg = "pex_get_status failed"; 39169695Skan } 40169695Skan } 41169695Skan pex_free (obj); 42169695Skan return errmsg; 43169695Skan} 44