- drain_input (state);
-}
-
-\f
-/* Subprocess.
- */
-
-static void
-subproc_cb (XtPointer closure, int *source, XtInputId *id)
-{
- p_state *state = (p_state *) closure;
- state->input_available_p = True;
-}
-
-
-static void
-launch_text_generator (p_state *state)
-{
- char buf[255];
- char *oprogram = get_string_resource ("program", "Program");
- char *program = (char *) malloc (strlen (oprogram) + 50);
-
- /* oprogram contains a "%d" where the current number of columns goes
- */
- strcpy (program, "( ");
- sprintf (program + strlen(program), oprogram, state->grid_width-1);
- strcat (program, " ) 2>&1");
-
-#ifdef HAVE_FORKPTY
- if(state->mode == 1)
- {
- int fd;
- struct winsize ws;
-
- ws.ws_row = state->grid_height - 1;
- ws.ws_col = state->grid_width - 2;
- ws.ws_xpixel = state->xgwa.width;
- ws.ws_ypixel = state->xgwa.height;
-
- state->pipe = NULL;
- if((state->pid = forkpty(&fd, NULL, NULL, &ws)) < 0)
- {
- /* Unable to fork */
- sprintf (buf, "%.100s: forkpty", progname);
- perror(buf);
- }
- else if(!state->pid)
- {
- /* This is the child fork. */
- char *av[10];
- int i = 0;
- if (putenv("TERM=vt100"))
- abort();
- av[i++] = "/bin/sh";
- av[i++] = "-c";
- av[i++] = program;
- av[i] = 0;
- execvp (av[0], av);
- sprintf (buf, "%.100s: %.100s", progname, oprogram);
- perror(buf);
- exit(1);
- }
- else
- {
- /* This is the parent fork. */
- state->pipe = fdopen(fd, "r+");
- state->pipe_id =
- XtAppAddInput (app, fileno (state->pipe),
- (XtPointer) (XtInputReadMask | XtInputExceptMask),
- subproc_cb, (XtPointer) state);
- }
- }
- else
-#endif /* HAVE_FORKPTY */
- {
- /* don't mess up controlling terminal if someone dumbly does
- "-pipe -program tcsh". */
- fclose (stdin);