static char *sccsid
= "@(#)wwenviron.c 3.7 84/01/11";
* 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:%s%s%s%s",
WWT_TERMCAP
, wp
->ww_w
.nc
, wp
->ww_w
.nr
,
wwavailmodes
& WWM_REV
? WWT_REV
: "",
wwavailmodes
& WWM_UL
? WWT_UL
: "",
wwavailmodes
& WWM_GRP
? WWT_GRP
: "",