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 <stdlib.h> |
9 |
|
#include <stdio.h> |
10 |
< |
#include <sys/types.h> |
10 |
> |
#include <string.h> |
11 |
|
#include <signal.h> |
12 |
|
#include <fcntl.h> |
13 |
+ |
#include <unistd.h> |
14 |
+ |
|
15 |
+ |
#include "selcall.h" |
16 |
|
#include "netproc.h" |
17 |
+ |
#include "paths.h" |
18 |
|
#include "vfork.h" |
17 |
– |
/* select call compatibility stuff */ |
18 |
– |
#ifndef FD_SETSIZE |
19 |
– |
#include <sys/param.h> |
20 |
– |
#define FD_SETSIZE NOFILE /* maximum # select file descriptors */ |
21 |
– |
#endif |
22 |
– |
#ifndef FD_SET |
23 |
– |
#ifndef NFDBITS |
24 |
– |
#define NFDBITS (8*sizeof(int)) /* number of bits per fd_mask */ |
25 |
– |
#endif |
26 |
– |
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) |
27 |
– |
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) |
28 |
– |
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) |
29 |
– |
#ifndef BSD |
30 |
– |
#define bzero(d,n) (void)memset(d,0,n) |
31 |
– |
#endif |
32 |
– |
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) |
33 |
– |
#endif |
19 |
|
|
20 |
|
PSERVER *pslist = NULL; /* global process server list */ |
21 |
|
|
22 |
< |
static PROC *pindex[FD_SETSIZE]; /* process index table */ |
22 |
> |
static NETPROC *pindex[FD_SETSIZE]; /* process index table */ |
23 |
|
|
24 |
|
static char ourhost[64]; /* this host name */ |
25 |
< |
static char ourdir[128]; /* our working directory */ |
25 |
> |
static char ourdir[PATH_MAX]; /* our working directory */ |
26 |
|
static char ouruser[32]; /* our user name */ |
27 |
|
static char *ourshell; /* our user's shell */ |
28 |
|
|
31 |
|
|
32 |
|
extern char *remsh; /* externally defined remote shell program */ |
33 |
|
|
49 |
– |
extern char *malloc(), *realloc(); |
50 |
– |
extern char *getenv(); |
34 |
|
|
52 |
– |
|
35 |
|
PSERVER * |
36 |
|
addpserver(host, dir, usr, np) /* add a new process server */ |
37 |
|
char *host, *dir, *usr; |
41 |
|
/* allocate the struct */ |
42 |
|
if (np < 1) |
43 |
|
return(NULL); |
44 |
< |
ps = (PSERVER *)malloc(sizeof(PSERVER)+(np-1)*sizeof(PROC)); |
44 |
> |
ps = (PSERVER *)malloc(sizeof(PSERVER)+(np-1)*sizeof(NETPROC)); |
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 |
|
|
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 |
|
|
151 |
|
char *command; |
152 |
|
int (*compf)(); |
153 |
|
{ |
154 |
< |
char udirt[128]; |
154 |
> |
char udirt[PATH_MAX]; |
155 |
|
char *av[16]; |
156 |
|
int pfd[2], pid; |
157 |
|
register int i; |
232 |
|
{ |
233 |
|
char errbuf[BUFSIZ]; |
234 |
|
int nr; |
235 |
< |
register PROC *pp; |
235 |
> |
register NETPROC *pp; |
236 |
|
/* look up associated process */ |
237 |
|
if ((pp = pindex[fd]) == NULL) |
238 |
|
abort(); /* serious consistency error */ |
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); |
286 |
|
int pn; |
287 |
|
int status; |
288 |
|
{ |
289 |
< |
register PROC *pp; |
289 |
> |
register NETPROC *pp; |
290 |
|
|
291 |
|
pp = ps->proc + pn; |
292 |
|
if (pp->cf != NULL) /* client cleanup */ |
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; |