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.11 by schorsch, Mon Jun 30 14:59:13 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 <unistd.h>
12 +
13 + #include "selcall.h"
14   #include "netproc.h"
15 + #include "paths.h"
16   #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
17  
18   PSERVER *pslist = NULL;         /* global process server list */
19  
20   static PROC     *pindex[FD_SETSIZE];    /* process index table */
21  
22   static char     ourhost[64];    /* this host name */
23 < static char     ourdir[128];    /* our working directory */
23 > static char     ourdir[PATH_MAX];       /* our working directory */
24   static char     ouruser[32];    /* our user name */
25   static char     *ourshell;      /* our user's shell */
26  
27   static fd_set   errdesc;        /* error file descriptors */
28   static int      maxfd;          /* maximum assigned descriptor */
29  
30 < extern char     *malloc(), *realloc();
30 > extern char     *remsh;         /* externally defined remote shell program */
31 >
32   extern char     *getenv();
33  
34  
# Line 71 | Line 45 | int    np;
45          if (ps == NULL)
46                  return(NULL);
47          if (!ourhost[0]) {              /* initialize */
48 <                char    dirtmp[128];
48 >                char    dirtmp[PATH_MAX];
49                  register char   *cp;
50                  register int    len;
51  
# Line 150 | Line 124 | PSERVER        *ps;
124                                          /* remove server from list */
125          psp->next = ps->next;
126          pslist = pstart.next;
127 <        free((char *)ps);               /* free associated memory */
127 >        free((void *)ps);               /* free associated memory */
128   }
129  
130  
# Line 177 | Line 151 | register PSERVER       *ps;
151   char    *command;
152   int     (*compf)();
153   {
154 <        char    *av[12];
154 >        char    udirt[PATH_MAX];
155 >        char    *av[16];
156          int     pfd[2], pid;
157          register int    i;
158  
# Line 205 | Line 180 | int    (*compf)();
180                          close(pfd[1]);
181                  }
182                  if (ps->hostname[0]) {          /* rsh command */
183 <                        av[i=0] = RSH;
183 >                        av[i=0] = remsh;
184                          av[++i] = ps->hostname;
185 <                        av[++i] = "-n";         /* no stdin */
186 <                        if (ps->username[0]) {
185 >                        av[++i] = "-n";                 /* no stdin */
186 >                        if (ps->username[0]) {          /* different user */
187                                  av[++i] = "-l";
188                                  av[++i] = ps->username;
189 +                                av[++i] = "cd";
190 +                                udirt[0] = '~';
191 +                                strcpy(udirt+1, ouruser);
192 +                                av[++i] = udirt;
193 +                                av[++i] = ";";
194                          }
195 <                        if (ps->directory[0]) {
195 >                        if (ps->directory[0]) {         /* change directory */
196                                  av[++i] = "cd";
197                                  av[++i] = ps->directory;
198                                  av[++i] = ";";
# Line 267 | Line 247 | int    fd;
247          if (pp->elen == 0)
248                  pp->errs = (char *)malloc(nr+1);
249          else
250 <                pp->errs = (char *)realloc(pp->errs, pp->elen+nr+1);
250 >                pp->errs = (char *)realloc((void *)pp->errs, pp->elen+nr+1);
251          if (pp->errs == NULL) {
252                  perror("malloc failed");
253                  exit(1);
# Line 314 | Line 294 | int    status;
294          close(pp->efd);                         /* close error stream */
295          pindex[pp->efd] = NULL;
296          FD_CLR(pp->efd, &errdesc);
297 <        free((char *)pp->errs);
297 >        free((void *)pp->errs);
298          pp->com = NULL;                         /* clear settings */
299          pp->pid = -1;
300          pp->efd = -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines