ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/netproc.c
(Generate patch)

Comparing ray/src/util/netproc.c (file contents):
Revision 2.2 by greg, Wed Feb 7 16:42:45 1996 UTC vs.
Revision 2.9 by greg, Sat Feb 22 02:07:30 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1996 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Parallel network process handling routines
6   */
7  
8   #include <stdio.h>
12 #include <sys/types.h>
9   #include <signal.h>
10   #include <fcntl.h>
11 + #include "selcall.h"
12   #include "netproc.h"
13 + #include "paths.h"
14   #include "vfork.h"
17                                        /* Remote shell location */
18 #ifdef sgi
19 #define RSH             "/usr/bsd/rsh"
20 #endif
21 #ifdef _AUX_SOURCE
22 #define RSH             "/usr/bin/remsh"
23 #endif
24 #ifndef RSH
25 #define RSH             "/usr/ucb/rsh"
26 #endif
27                                        /* select call compatibility stuff */
28 #ifndef FD_SETSIZE
29 #include <sys/param.h>
30 #define FD_SETSIZE      NOFILE          /* maximum # select file descriptors */
31 #endif
32 #ifndef FD_SET
33 #ifndef NFDBITS
34 #define NFDBITS         (8*sizeof(int)) /* number of bits per fd_mask */
35 #endif
36 #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
37 #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
38 #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
39 #ifndef BSD
40 #define bzero(d,n)      (void)memset(d,0,n)
41 #endif
42 #define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
43 #endif
15  
16   PSERVER *pslist = NULL;         /* global process server list */
17  
18   static PROC     *pindex[FD_SETSIZE];    /* process index table */
19  
20   static char     ourhost[64];    /* this host name */
21 < static char     ourdir[128];    /* our working directory */
21 > static char     ourdir[MAXPATH];        /* our working directory */
22   static char     ouruser[32];    /* our user name */
23   static char     *ourshell;      /* our user's shell */
24  
25   static fd_set   errdesc;        /* error file descriptors */
26   static int      maxfd;          /* maximum assigned descriptor */
27  
28 < extern char     *malloc(), *realloc();
28 > extern char     *remsh;         /* externally defined remote shell program */
29 >
30   extern char     *getenv();
31  
32  
# Line 71 | Line 43 | int    np;
43          if (ps == NULL)
44                  return(NULL);
45          if (!ourhost[0]) {              /* initialize */
46 <                char    dirtmp[128];
46 >                char    dirtmp[MAXPATH];
47                  register char   *cp;
48                  register int    len;
49  
50                  strcpy(ourhost, myhostname());
51 <                getcwd(dirtmp, sizeof(dirtmp));
51 >                getwd(dirtmp);
52                  if ((cp = getenv("HOME")) != NULL) {
53                          if (!strcmp(cp, dirtmp))
54                                  ourdir[0] = '\0';
# Line 150 | Line 122 | PSERVER        *ps;
122                                          /* remove server from list */
123          psp->next = ps->next;
124          pslist = pstart.next;
125 <        free((char *)ps);               /* free associated memory */
125 >        free((void *)ps);               /* free associated memory */
126   }
127  
128  
# Line 177 | Line 149 | register PSERVER       *ps;
149   char    *command;
150   int     (*compf)();
151   {
152 <        char    *av[12];
152 >        char    udirt[MAXPATH];
153 >        char    *av[16];
154          int     pfd[2], pid;
155          register int    i;
156  
# Line 205 | Line 178 | int    (*compf)();
178                          close(pfd[1]);
179                  }
180                  if (ps->hostname[0]) {          /* rsh command */
181 <                        av[i=0] = RSH;
181 >                        av[i=0] = remsh;
182                          av[++i] = ps->hostname;
183 <                        av[++i] = "-n";         /* no stdin */
184 <                        if (ps->username[0]) {
183 >                        av[++i] = "-n";                 /* no stdin */
184 >                        if (ps->username[0]) {          /* different user */
185                                  av[++i] = "-l";
186                                  av[++i] = ps->username;
187 +                                av[++i] = "cd";
188 +                                udirt[0] = '~';
189 +                                strcpy(udirt+1, ouruser);
190 +                                av[++i] = udirt;
191 +                                av[++i] = ";";
192                          }
193 <                        if (ps->directory[0]) {
193 >                        if (ps->directory[0]) {         /* change directory */
194                                  av[++i] = "cd";
195                                  av[++i] = ps->directory;
196                                  av[++i] = ";";
# Line 314 | Line 292 | int    status;
292          close(pp->efd);                         /* close error stream */
293          pindex[pp->efd] = NULL;
294          FD_CLR(pp->efd, &errdesc);
295 <        free((char *)pp->errs);
295 >        free((void *)pp->errs);
296          pp->com = NULL;                         /* clear settings */
297          pp->pid = -1;
298          pp->efd = -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines