@@ -859,6 +859,7 @@ static void forkchild(struct job *jp, union node *n, int mode)
closescript();
clear_traps();
+ clearredir();
#if JOBS
/* do job control only in root shell */
@@ -66,15 +66,7 @@
# define PIPESIZE PIPE_BUF
#endif
-
-MKINIT
-struct redirtab {
- struct redirtab *next;
- int renamed[10];
-};
-
-
-MKINIT struct redirtab *redirlist;
+struct redirtab *redirlist;
/* Bit map of currently closed file descriptors. */
static unsigned closed_redirs;
@@ -41,13 +41,22 @@
#endif
#define REDIR_SAVEFD2 03 /* set preverrout */
-struct redirtab;
+struct redirtab {
+ struct redirtab *next;
+ int renamed[10];
+};
+
+extern struct redirtab *redirlist;
+
union node;
void redirect(union node *, int);
void popredir(int);
-void clearredir(void);
int savefd(int, int);
int redirectsafe(union node *, int);
void unwindredir(struct redirtab *stop);
struct redirtab *pushredir(union node *redir);
+static inline void clearredir(void)
+{
+ redirlist = NULL;
+}