static char *sccsid
= "@(#)wwenviron.c 3.6 83/12/03";
* Set up the environment of this process to run in window 'wp'.
* Can't report errors in any intelligent way, because the parent
* hangs in vfork() until we die, but we can't die until output
* drains (i.e. deadlock). So don't say anything.
static char **termcap
= 0;
if (ioctl(i
, (int)TIOCNOTTY
, (char *)0) < 0)
if ((i
= open(wp
->ww_ttyname
, 2)) < 0)
for (i
= wwdtablesize
- 1; i
> 2; i
--)
if (ioctl(0, (int)TIOCSPGRP
, &pgrp
) < 0)
(void) setpgrp(pgrp
, pgrp
);
* Do this only once if vfork().
for (i
= 0, p
= environ
; *p
; p
++, i
++)
env
= (char **)malloc((unsigned)(i
+ 3) * sizeof (char *));
if ((tbuf
= malloc((unsigned) 1024)) == 0)
for (p
= environ
, q
= env
; *p
; p
++, q
++) {
if (strncmp(*p
, "TERM=", 5) == 0)
else if (strncmp(*p
, "TERMCAP=", 8) == 0)
*termcap
= sprintf(tbuf
, "TERMCAP=%sco#%d:li#%d:",
WWT_TERMCAP
, wp
->ww_w
.nc
, wp
->ww_w
.nr
);
if (wwavailmodes
& WWM_REV
)
(void) strcat(tbuf
, WWT_REV
);
if (wwavailmodes
& WWM_UL
)
(void) strcat(tbuf
, WWT_UL
);
(void) strcat(tbuf
, wwkeys
);