- Timestamp:
- Oct 7, 2007 6:42:48 PM (17 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/Makefile.kmk
r1210 r1212 47 47 output.c \ 48 48 parser.c \ 49 redir.c \ 49 50 show.c \ 50 51 syntax.c \ … … 55 56 bltin/test.c \ 56 57 \ 57 redir.c \58 58 bltin/kill.c \ 59 59 $(PATH_TARGET)/arith.c \ -
trunk/src/kash/generated/init.c
r1208 r1212 160 160 }; 161 161 162 extern struct redirtab *redirlist;162 //extern struct redirtab *redirlist; 163 163 164 164 extern char sigmode[NSIG]; /* current value of signal */ -
trunk/src/kash/redir.c
r1208 r1212 85 85 86 86 87 MKINIT struct redirtab *redirlist;87 //MKINIT struct redirtab *redirlist; 88 88 89 89 /* … … 92 92 * if it hasn't already been redirected. 93 93 */ 94 int fd0_redirected = 0;95 96 STATIC void openredirect( union node *, char[10], int);97 STATIC int openhere( union node *);94 //int fd0_redirected = 0; 95 96 STATIC void openredirect(shinstance *, union node *, char[10], int); 97 STATIC int openhere(shinstance *, union node *); 98 98 99 99 … … 107 107 108 108 void 109 redirect( union node *redir, int flags)109 redirect(shinstance *psh, union node *redir, int flags) 110 110 { 111 111 union node *n; … … 126 126 for (i = 0 ; i < 10 ; i++) 127 127 sv->renamed[i] = EMPTY; 128 sv->next = redirlist;129 redirlist = sv;128 sv->next = psh->redirlist; 129 psh->redirlist = sv; 130 130 } 131 131 for (n = redir ; n ; n = n->nfile.next) { … … 143 143 case EBADF: 144 144 if (!try) { 145 openredirect( n, memory, flags);145 openredirect(psh, n, memory, flags); 146 146 try++; 147 147 goto again; … … 163 163 } 164 164 if (fd == 0) 165 fd0_redirected++;165 psh->fd0_redirected++; 166 166 if (!try) 167 openredirect( n, memory, flags);167 openredirect(psh, n, memory, flags); 168 168 } 169 169 if (memory[1]) … … 175 175 176 176 STATIC void 177 openredirect( union node *redir, char memory[10], int flags)177 openredirect(shinstance *psh, union node *redir, char memory[10], int flags) 178 178 { 179 179 int fd = redir->nfile.fd; … … 232 232 case NHERE: 233 233 case NXHERE: 234 f = openhere( redir);234 f = openhere(psh, redir); 235 235 break; 236 236 default: … … 258 258 259 259 STATIC int 260 openhere( union node *redir)260 openhere(shinstance *psh, union node *redir) 261 261 { 262 262 int pip[2]; 263 int len = 0;264 265 if ( pipe(pip) < 0)263 size_t len = 0; 264 265 if (shfile_pipe(&psh->fdtab, pip) < 0) 266 266 error(psh, "Pipe call failed"); 267 267 if (redir->type == NHERE) { … … 299 299 300 300 void 301 popredir( void)302 { 303 struct redirtab *rp = redirlist;301 popredir(shinstance *psh) 302 { 303 struct redirtab *rp = psh->redirlist; 304 304 int i; 305 305 … … 307 307 if (rp->renamed[i] != EMPTY) { 308 308 if (i == 0) 309 fd0_redirected--;309 psh->fd0_redirected--; 310 310 shfile_close(&psh->fdtab, i); 311 311 if (rp->renamed[i] >= 0) { … … 316 316 } 317 317 INTOFF; 318 redirlist = rp->next;318 psh->redirlist = rp->next; 319 319 ckfree(rp); 320 320 INTON; … … 330 330 331 331 RESET { 332 while ( redirlist)332 while (psh->redirlist) 333 333 popredir(psh); 334 334 } … … 351 351 352 352 void 353 clearredir(vforked) 354 int vforked; 353 clearredir(shinstance *psh, int vforked) 355 354 { 356 355 struct redirtab *rp; 357 356 int i; 358 357 359 for (rp = redirlist ; rp ; rp = rp->next) {358 for (rp = psh->redirlist ; rp ; rp = rp->next) { 360 359 for (i = 0 ; i < 10 ; i++) { 361 360 if (rp->renamed[i] >= 0) { … … 381 380 int newfd; 382 381 383 newfd = shfile_fcntl( psh, from, F_DUPFD, to);382 newfd = shfile_fcntl(&psh->fdtab, from, F_DUPFD, to); 384 383 if (newfd < 0) { 385 384 if (errno == EMFILE)
Note:
See TracChangeset
for help on using the changeset viewer.