redir.c (213760) | redir.c (213811) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#ifndef lint 34#if 0 35static char sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#ifndef lint 34#if 0 35static char sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/bin/sh/redir.c 213760 2010-10-13 04:01:01Z obrien $"); | 39__FBSDID("$FreeBSD: head/bin/sh/redir.c 213811 2010-10-13 22:18:03Z obrien $"); |
40 41#include <sys/types.h> 42#include <sys/stat.h> 43#include <signal.h> 44#include <string.h> 45#include <fcntl.h> 46#include <errno.h> 47#include <unistd.h> --- 30 unchanged lines hidden (view full) --- 78 79/* 80 * We keep track of whether or not fd0 has been redirected. This is for 81 * background commands, where we want to redirect fd0 to /dev/null only 82 * if it hasn't already been redirected. 83*/ 84static int fd0_redirected = 0; 85 | 40 41#include <sys/types.h> 42#include <sys/stat.h> 43#include <signal.h> 44#include <string.h> 45#include <fcntl.h> 46#include <errno.h> 47#include <unistd.h> --- 30 unchanged lines hidden (view full) --- 78 79/* 80 * We keep track of whether or not fd0 has been redirected. This is for 81 * background commands, where we want to redirect fd0 to /dev/null only 82 * if it hasn't already been redirected. 83*/ 84static int fd0_redirected = 0; 85 |
86STATIC void openredirect(union node *, char[10 ]); 87STATIC int openhere(union node *); | 86static void openredirect(union node *, char[10 ]); 87static int openhere(union node *); |
88 89 90/* 91 * Process a list of redirection commands. If the REDIR_PUSH flag is set, 92 * old file descriptors are stashed away so that the redirection can be 93 * undone by calling popredir. If the REDIR_BACKQ flag is set, then the 94 * standard output, and the standard error if it becomes a duplicate of 95 * stdout, is saved in memory. --- 47 unchanged lines hidden (view full) --- 143 } 144 if (memory[1]) 145 out1 = &memout; 146 if (memory[2]) 147 out2 = &memout; 148} 149 150 | 88 89 90/* 91 * Process a list of redirection commands. If the REDIR_PUSH flag is set, 92 * old file descriptors are stashed away so that the redirection can be 93 * undone by calling popredir. If the REDIR_BACKQ flag is set, then the 94 * standard output, and the standard error if it becomes a duplicate of 95 * stdout, is saved in memory. --- 47 unchanged lines hidden (view full) --- 143 } 144 if (memory[1]) 145 out1 = &memout; 146 if (memory[2]) 147 out2 = &memout; 148} 149 150 |
151STATIC void | 151static void |
152openredirect(union node *redir, char memory[10]) 153{ 154 struct stat sb; 155 int fd = redir->nfile.fd; 156 char *fname; 157 int f; 158 159 /* --- 75 unchanged lines hidden (view full) --- 235 236 237/* 238 * Handle here documents. Normally we fork off a process to write the 239 * data to a pipe. If the document is short, we can stuff the data in 240 * the pipe without forking. 241 */ 242 | 152openredirect(union node *redir, char memory[10]) 153{ 154 struct stat sb; 155 int fd = redir->nfile.fd; 156 char *fname; 157 int f; 158 159 /* --- 75 unchanged lines hidden (view full) --- 235 236 237/* 238 * Handle here documents. Normally we fork off a process to write the 239 * data to a pipe. If the document is short, we can stuff the data in 240 * the pipe without forking. 241 */ 242 |
243STATIC int | 243static int |
244openhere(union node *redir) 245{ 246 int pip[2]; 247 int len = 0; 248 249 if (pipe(pip) < 0) 250 error("Pipe call failed: %s", strerror(errno)); 251 if (redir->type == NHERE) { --- 99 unchanged lines hidden --- | 244openhere(union node *redir) 245{ 246 int pip[2]; 247 int len = 0; 248 249 if (pipe(pip) < 0) 250 error("Pipe call failed: %s", strerror(errno)); 251 if (redir->type == NHERE) { --- 99 unchanged lines hidden --- |