/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1990-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20/*21* Glenn Fowler22* AT&T Research23*24* coshell system(3)25*/2627#include "colib.h"2829int30cosystem(const char* cmd)31{32Coshell_t* co;33Cojob_t* cj;34int status;3536if (!cmd)37return !eaccess(pathshell(), X_OK);38if (!(co = coopen(NiL, CO_ANY, NiL)))39return -1;40if (cj = coexec(co, cmd, CO_SILENT, NiL, NiL, NiL))41cj = cowait(co, cj, -1);42if (!cj)43return -1;4445/*46* synthesize wait() status from shell status47* lack of synthesis is the standard's proprietary sellout48*/4950status = cj->status;51if (EXITED_TERM(status))52status &= ((1<<(EXIT_BITS-1))-1);53else54status = (status & ((1<<EXIT_BITS)-1)) << EXIT_BITS;55return status;56}575859