* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
#if defined(_POSIX_SOURCE)
extern pid_t _fork(void);
extern pid_t _wait(int *);
extern void _execve(const char *path, const char ** argv, const char ** envp);
extern const char ***_penviron;
static const char *exec_tab[] = {
"-c", /* argument to the shell */
NULL, /* to be filled with user command */
NULL /* terminating NULL */
int pid, exitstatus, waitval;
if ((pid = _fork()) < 0) return str ? -1 : 0;
for (i = 3; i <= 20; i++)
if (!str) str = "cd ."; /* just testing for a shell */
exec_tab[2] = str; /* fill in command */
_execve("/bin/sh", exec_tab, *_penviron);
/* get here if execve fails ... */
_exit(FAIL); /* see manual page */
while ((waitval = _wait(&exitstatus)) != pid) {
if (waitval == -1) break;
/* no child ??? or maybe interrupted ??? */
if (exitstatus == FAIL << 8) /* execve() failed */
else exitstatus = 1; /* /bin/sh exists */