+ }
+ }
+}
+
+wterm(p)
+ register struct tab *p;
+{
+ if (p->wpid != 0) {
+ kill(p->wpid, SIGKILL);
+ }
+ p->wpid = 0;
+}
+
+wstart(p)
+ register struct tab *p;
+{
+ int npid = fork();
+
+ if (npid == 0) {
+/*
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGALRM, SIG_DFL);
+ signal(SIGTSTP, SIG_IGN);
+*/
+ execit(p->wcmd, p->line);
+ exit(0);
+ }
+ p->wpid = npid;
+}
+
+#define NARGS 20 /* must be at lease 4 */
+#define ARGLEN 512 /* total size for all the argument strings */
+
+execit(s, arg)
+ char *s;
+ char *arg; /* last argument on line */
+{
+ char *argv[NARGS], args[ARGLEN], *envp[1];
+ register char *sp = s;
+ register char *ap = args;
+ register char c;
+ register int i;
+
+ /*
+ * First we have to set up the argument vector.
+ * "prog arg1 arg2" maps to exec("prog", "-", "arg1", "arg2").
+ */
+ for (i = 1; i < NARGS - 2; i++) {
+ argv[i] = ap;
+ for (EVER) {
+ if ((c = *sp++) == '\0' || ap >= &args[ARGLEN-1]) {
+ *ap = '\0';
+ goto done;
+ }
+ if (c == ' ') {
+ *ap++ = '\0';
+ while (*sp == ' ')
+ sp++;
+ if (*sp == '\0')
+ goto done;
+ break;
+ }
+ *ap++ = c;
+ }