coopen.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1990-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* open a new coshell
*/
#include "colib.h"
#include <namval.h>
#include <proc.h>
#include <sfdisc.h>
#include <tok.h>
{
"cross", CO_CROSS,
"debug", CO_DEBUG,
"devfd", CO_DEVFD,
"ignore", CO_IGNORE,
"orphan", CO_ORPHAN,
"silent", CO_SILENT,
"separate", CO_SEPARATE,
"service", CO_SERVICE,
0, 0
};
/*
* called when ident sequence hung
*/
static void
{
}
/*
* close all open coshells
*/
static void
clean(void)
{
}
#ifdef SIGCONT
/*
* pass job control signals to the coshell and self
*/
static void
{
}
#endif
/*
* called by stropt() to set options
*/
static int
{
char* s;
char** a;
NoP(v);
if (p)
{
if (n)
{
if (((Namval_t*)p)->value == CO_SERVICE && v && (cs = vmnewof(co->vm, 0, Coservice_t, 1, 2 * strlen(v))))
{
while (*s = *v++)
if (*s++ == ':')
{
*(s - 1) = 0;
if (*v == '-')
{
v++;
if (*v == '-')
v++;
}
{
*a++ = s;
*s++ = '-';
*s++ = '-';
}
}
*a = 0;
}
}
else
}
return 0;
}
{
register char* s;
register int i;
char* t;
int n;
int pio[4];
long ops[5];
char devfd[16];
char* av[8];
char* ev[2];
return co;
{
if (vm)
return 0;
}
if (attributes)
{
}
{
flags = 0;
proc = 0;
}
else
{
for (i = 0; i < elementsof(pio); i++)
pio[i] = -1;
{
goto bad;
}
for (i = 0; i < elementsof(pio); i++)
{
pio[i] = n;
}
{
goto bad;
}
ops[4] = 0;
}
for (i = 0; i < elementsof(sh); i++)
{
{
av[0] = t + 1;
av[n] = 0;
ev[1] = 0;
if ((co->mode & CO_MODE_SEPARATE) || (proc = procopen(s, av, ev, ops, (co->flags & (CO_SHELL|CO_ORPHAN)) ? (PROC_ORPHAN|PROC_DAEMON|PROC_IGNORE) : (PROC_DAEMON|PROC_IGNORE))))
{
free(s);
if (proc)
{
}
break;
}
}
free(s);
}
if (i >= elementsof(sh))
{
goto bad;
}
{
/*
* send the shell identification sequence
*/
{
goto bad;
}
if (t = getenv(CO_ENV_ATTRIBUTES))
{
if (attributes)
}
if (attributes)
sfstrclose(sp);
if (i)
{
goto nope;
}
i = alarm(30);
{
goto nope;
}
alarm(i);
switch (*s)
{
case 'o':
/*FALLTHROUGH*/
case 'b':
s = cobinit;
break;
case 'k':
s = cokinit;
break;
case 'i': /* NOTE: 'i' is obsolete */
case 's':
for (;;)
{
if (t = strchr(s, ','))
*t = 0;
if (streq(s, CO_OPT_ACK))
else if (streq(s, CO_OPT_INDIRECT))
if (!(s = t))
break;
s++;
}
break;
default:
goto nope;
}
if (s)
{
{
goto nope;
}
}
}
{
#ifdef SIGCONT
#ifdef SIGTSTP
#endif
#ifdef SIGTTIN
#endif
#ifdef SIGTTOU
#endif
#endif
{
}
}
return co;
bad:
n = errno;
{
}
for (i = 0; i < elementsof(pio); i++)
if (pio[i] >= 0)
errno = n;
return 0;
nope:
i = errno;
if (!(s = sh[1]) || (s = (t = strrchr(s, '/')) ? (t + 1) : s) && !strmatch(s, "?(k)sh") && !streq(s, CO_ID))
errno = i;
return 0;
}
/*
* set coshell attributes
*/
int
{
return 0;
}