@@ -34,6 +34,9 @@
* @(#)error.h 8.2 (Berkeley) 5/4/95
*/
+#ifndef _SRC_ERROR_H
+#define _SRC_ERROR_H
+
#include <setjmp.h>
#include <signal.h>
@@ -127,3 +130,5 @@ void exerror(int, const char *, ...) __attribute__((__noreturn__));
const char *errmsg(int, int);
void sh_warnx(const char *, ...);
+
+#endif /* _SRC_ERROR_H */
@@ -952,9 +952,10 @@ forkshell(struct job *jp, union node *n, int mode)
TRACE(("forkshell(%%%d, %p, %d) called\n", jobno(jp), n, mode));
pid = fork();
- if (pid == 0)
+ if (pid == 0) {
+ handler = &main_handler;
forkchild(jp, n, mode);
- else
+ } else
forkparent(jp, n, mode, pid);
return pid;
@@ -71,6 +71,7 @@ int *dash_errno;
short profile_buf[16384];
extern int etext();
#endif
+struct jmploc main_handler;
STATIC void read_profile(const char *);
STATIC char *find_dot_file(char *);
@@ -90,7 +91,6 @@ main(int argc, char **argv)
{
char *shinit;
volatile int state;
- struct jmploc jmploc;
struct stackmark smark;
int login;
@@ -102,7 +102,7 @@ main(int argc, char **argv)
monitor(4, etext, profile_buf, sizeof profile_buf, 50);
#endif
state = 0;
- if (unlikely(setjmp(jmploc.loc))) {
+ if (unlikely(setjmp(main_handler.loc))) {
int e;
int s;
@@ -137,7 +137,7 @@ main(int argc, char **argv)
else
goto state4;
}
- handler = &jmploc;
+ handler = &main_handler;
#ifdef DEBUG
opentrace();
trputs("Shell args: "); trargs(argv);
@@ -35,6 +35,7 @@
*/
#include <errno.h>
+#include "error.h"
/* pid of main shell */
extern int rootpid;
@@ -49,6 +50,8 @@ extern int *dash_errno;
#define errno (*dash_errno)
#endif
+extern struct jmploc main_handler;
+
void readcmdfile(char *);
int dotcmd(int, char **);
int exitcmd(int, char **);