Back to index

cell-binutils  2.17cvs20070401
pex-one.c
Go to the documentation of this file.
00001 /* Execute a program and wait for a result.
00002    Copyright (C) 2005 Free Software Foundation, Inc.
00003 
00004 This file is part of the libiberty library.
00005 Libiberty is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Library General Public
00007 License as published by the Free Software Foundation; either
00008 version 2 of the License, or (at your option) any later version.
00009 
00010 Libiberty is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Library General Public License for more details.
00014 
00015 You should have received a copy of the GNU Library General Public
00016 License along with libiberty; see the file COPYING.LIB.  If not,
00017 write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
00018 Boston, MA 02110-1301, USA.  */
00019 
00020 #include "config.h"
00021 #include "libiberty.h"
00022 
00023 const char *
00024 pex_one (int flags, const char *executable, char * const *argv,
00025         const char *pname, const char *outname, const char *errname,
00026         int *status, int *err)
00027 {
00028   struct pex_obj *obj;
00029   const char *errmsg;
00030 
00031   obj = pex_init (0, pname, NULL);
00032   errmsg = pex_run (obj, flags, executable, argv, outname, errname, err);
00033   if (errmsg == NULL)
00034     {
00035       if (!pex_get_status (obj, 1, status))
00036        {
00037          *err = 0;
00038          errmsg = "pex_get_status failed";
00039        }
00040     }
00041   pex_free (obj);
00042   return errmsg;  
00043 }