1: #ifndef lint
   2: static char sccsid[] = "@(#)wwenviron.c	3.14 5/2/86";
   3: #endif
   4: 
   5: /*
   6:  * Copyright (c) 1983 Regents of the University of California,
   7:  * All rights reserved.  Redistribution permitted subject to
   8:  * the terms of the Berkeley Software License Agreement.
   9:  */
  10: 
  11: #include "ww.h"
  12: #include <sys/signal.h>
  13: 
  14: /*
  15:  * Set up the environment of this process to run in window 'wp'.
  16:  */
  17: wwenviron(wp)
  18: register struct ww *wp;
  19: {
  20:     register i;
  21:     int pgrp = getpid();
  22: 
  23:     if ((i = open("/dev/tty", 0)) < 0)
  24:         goto bad;
  25:     if (ioctl(i, TIOCNOTTY, (char *)0) < 0)
  26:         goto bad;
  27:     (void) close(i);
  28:     if ((i = wp->ww_socket) < 0 && (i = open(wp->ww_ttyname, 2)) < 0)
  29:         goto bad;
  30:     (void) dup2(i, 0);
  31:     (void) dup2(i, 1);
  32:     (void) dup2(i, 2);
  33:     for (i = wwdtablesize - 1; i > 2; i--)
  34:         (void) close(i);
  35:     (void) ioctl(0, TIOCSPGRP, (char *)&pgrp);
  36:     (void) setpgrp(pgrp, pgrp);
  37:     (void) signal(SIGPIPE, SIG_DFL);
  38:     (void) sprintf(wwwintermcap, "TERMCAP=%sco#%d:li#%d:%s%s%s%s%s",
  39:         WWT_TERMCAP, wp->ww_w.nc, wp->ww_w.nr,
  40:         wwavailmodes & WWM_REV ? WWT_REV : "",
  41:         wwavailmodes & WWM_UL ? WWT_UL : "",
  42:         wwavailmodes & WWM_GRP ? WWT_GRP : "",
  43:         wwavailmodes & WWM_USR ? WWT_USR : "",
  44:         wwkeys);
  45:     return 0;
  46: bad:
  47:     wwerrno = WWE_SYS;
  48:     return -1;
  49: }

Defined functions

wwenviron defined in line 17; used 1 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1988-06-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2089
Valid CSS Valid XHTML 1.0 Strict