Esempio n. 1
0
int popen_child()
{
	struct Task *thisTask = IExec->FindTask(0);

	char *command = (char *)thisTask->tc_UserData;
	size_t len;
	char *str;
	int argc;
	int number_of_arguments;
	char *argv[4];

	argv[0] = "sh";
	argv[1] = "-c";
	argv[2] = command ? command : NULL;
	argv[3] = NULL;

	// adebug("%s %ld  %s\n",__FUNCTION__,__LINE__,command?command:"NULL");

	/* We need to give this to sh via execvp, execvp expects filename,
	 * argv[]
	 */

	myexecvp(FALSE, argv[0], argv);
	if (command)
		IExec->FreeVec(command);

	IExec->Forbid();
	return 0;
}
Esempio n. 2
0
/*VARARGS1*/
int
execute(char *a, ...)	/* note: "exec" is already defined on u370 */
{
	va_list	ap;
	int	exitcode = -1;	/* initialize, to avoid warning */
	char	*argv[BUFSIZ];
	pid_t	p;

	/* fork and exec the program or shell script */
	endwin();	/* restore the terminal modes */
	mousecleanup();
	fflush(stdout);
	va_start(ap, a);
	for (p = 0; (argv[p] = va_arg(ap, char *)) != 0; p++)
		;
#if !HAVE_FORK
	/* HBB 20010313: in MSDOG, everything is completely different.
	 * No fork()/exec()/wait(), but rather a single libc call: */
        exitcode = spawnvp(P_WAIT, a, argv);
#else
	if ((p = myfork()) == 0) {
		myexecvp(a, argv);	/* child */
	}
	else {
		exitcode = join(p);	/* parent */
	}
#endif /* MSDOS */
	
	/* the menu and scrollbar may be changed by the command executed */
#if UNIXPC || !TERMINFO
# ifndef __DJGPP__ /* leave CRLF handling as is */      
	nonl();
# endif
	raw();	/* endwin() turns off cbreak mode so restore it */
	noecho();
#endif
	mousemenu();
	drawscrollbar(topline, nextline);
	va_end(ap);
	return(exitcode);
}