/***********************************************************************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 library interface25*/2627#ifndef _COSHELL_H28#define _COSHELL_H2930#include <ast.h>3132#if !_BLD_coshell3334#undef procrun35#define procrun(a,b,c) coprocrun(a,b,c)36#undef system37#define system(a) cosystem(a)3839#endif4041struct Coshell_s; typedef struct Coshell_s Coshell_t;42struct Cojob_s; typedef struct Cojob_s Cojob_t;4344/*45* DEPRECATED names for compatibility46*/4748#define COSHELL Coshell_t49#define COJOB Cojob_t5051#define CO_ID "coshell" /* library/command id */5253#define CO_ENV_ATTRIBUTES "COATTRIBUTES"/* coshell attributes env var */54#define CO_ENV_EXPORT "COEXPORT" /* coshell env var export list */55#define CO_ENV_HOST "HOSTNAME" /* coshell host name env var */56#define CO_ENV_MSGFD "_COSHELL_msgfd"/* msg fd */57#define CO_ENV_OPTIONS "COSHELL_OPTIONS"/* options environment var */58#define CO_ENV_PROC "NPROC" /* concurrency environment var */59#define CO_ENV_SHELL "COSHELL" /* coshell path environment var */60#define CO_ENV_TEMP "COTEMP" /* 10 char temp file base */61#define CO_ENV_TYPE "HOSTTYPE" /* coshell host type env var */6263#define CO_OPT_ACK "ack" /* wait for server coexec() ack */64#define CO_OPT_INDIRECT "indirect" /* indirect server connection */65#define CO_OPT_SERVER "server" /* server connection */6667#define CO_QUANT 100 /* time quanta per sec */6869#define CO_ANY 0x000001 /* return any open coshell */70#define CO_DEBUG 0x000002 /* library debug trace */71#define CO_EXPORT 0x000004 /* export everything */72#define CO_IGNORE 0x000008 /* ignore command errors */73#define CO_LOCAL 0x000010 /* local affinity */74#define CO_NONBLOCK 0x000020 /* don't block coexec if Q full */75#define CO_SHELL 0x000040 /* shell using coshell! */76#define CO_SILENT 0x000080 /* don't trace commands */7778#define CO_KSH 0x000100 /* coshell is ksh (readonly) */79#define CO_SERVER 0x000200 /* coshell is server (readonly) */80#define CO_OSH 0x000400 /* coshell is OLD (readonly) */8182#define CO_CROSS 0x000800 /* don't prepend local dirs */83#define CO_DEVFD 0x001000 /* coshell handles /dev/fd/# */8485#define CO_SERIALIZE 0x002000 /* serialize stdout and stderr */86#define CO_SERVICE 0x004000 /* service callouts */8788#define CO_APPEND 0x008000 /* append coexec() out/err */89#define CO_SEPARATE 0x010000 /* 1 shell+wait per coexec() */90#define CO_ORPHAN 0x020000 /* PROC_ORPHAN */9192#define CO_USER 0x100000 /* first user flag */9394struct Cojob_s /* coshell job info */95{96Coshell_t* coshell; /* running in this coshell */97int id; /* job id */98int status; /* exit status */99int flags; /* CO_* flags */100void* local; /* local info */101unsigned long user; /* user time in 1/CO_QUANT secs */102unsigned long sys; /* sys time in 1/CO_QUANT secs */103#ifdef _CO_JOB_PRIVATE_104_CO_JOB_PRIVATE_ /* library private additions */105#endif106};107108struct Coshell_s /* coshell connection info */109{110void* data; /* user data, initially 0 */111int flags; /* flags */112int outstanding; /* number of outstanding jobs */113int running; /* number of running jobs */114int total; /* number of coexec() jobs */115unsigned long user; /* user time in 1/CO_QUANT secs */116unsigned long sys; /* sys time in 1/CO_QUANT secs */117Sfio_t* msgfp; /* message stream for sfpoll() */118#ifdef _CO_SHELL_PRIVATE_119_CO_SHELL_PRIVATE_ /* library private additions */120#endif121};122123extern int coclose(Coshell_t*);124extern Cojob_t* coexec(Coshell_t*, const char*, int, const char*, const char*, const char*);125extern char* coinit(int);126extern int coexport(Coshell_t*, const char*, const char*);127extern int cokill(Coshell_t*, Cojob_t*, int);128extern Coshell_t* coopen(const char*, int, const char*);129extern void coquote(Sfio_t*, const char*, int);130extern int cosync(Coshell_t*, const char*, int, int);131extern Cojob_t* cowait(Coshell_t*, Cojob_t*, int);132133extern int cojobs(Coshell_t*);134extern int copending(Coshell_t*);135extern int cozombie(Coshell_t*);136137extern int coattr(Coshell_t*, const char*);138139extern int coprocrun(const char*, char**, int);140extern int cosystem(const char*);141142#endif143144145