* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)wwenviron.c 3.24 (Berkeley) %G%";
* Set up the environment of this process to run in window 'wp'.
if ((i
= open("/dev/tty", 0)) < 0)
if (ioctl(i
, TIOCNOTTY
, (char *)0) < 0)
if ((i
= wp
->ww_socket
) < 0) {
if ((i
= open(wp
->ww_ttyname
, 2)) < 0)
if (wwsettty(i
, &wwwintty
, (struct ww_tty
*)0) < 0)
winsize
.ws_row
= wp
->ww_w
.nr
;
winsize
.ws_col
= wp
->ww_w
.nc
;
winsize
.ws_xpixel
= winsize
.ws_ypixel
= 0;
if (ioctl(i
, TIOCSWINSZ
, (char *)&winsize
) < 0)
for (i
= wwdtablesize
- 1; i
> 2; i
--)
(void) ioctl(0, TIOCSCTTY
, 0);
(void) ioctl(0, TIOCSPGRP
, (char *)&pgrp
);
(void) setpgrp(pgrp
, pgrp
);
/* SIGPIPE is the only one we ignore */
(void) signal(SIGPIPE
, SIG_DFL
);
* Two conditions that make destructive setenv ok:
* 1. setenv() copies the string,
* 2. we've already called tgetent which copies the termcap entry.
(void) sprintf(buf
, "%sco#%d:li#%d:%s",
WWT_TERMCAP
, wp
->ww_w
.nc
, wp
->ww_w
.nr
, wwwintermcap
);
(void) setenv("TERMCAP", buf
, 1);
(void) sprintf(buf
, "%d", wp
->ww_id
+ 1);
(void) setenv("WINDOW_ID", buf
, 1);