ash: [ERROR] Set exitstatus in onint
Partially backported this commit: Date: Thu, 2 Oct 2014 21:07:55 +0800 [ERROR] Set exitstatus in onint Currently the exit status when we receive SIGINT is set in evalcommand which means that it doesn't always get set. For example, if you press CTRL-C at the prompt of an interactive dash, the exit status is not set to 130 as it is in many other Bourne shells. This patch fixes this by moving the setting of the exit status into onint which also simplifies evalcommand. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> The part after "if (evalbltin(cmdentry.u.cmd, argc, argv, flags))" causes testsuite failures in signal handling, so left unchanged. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
0840c91909
commit
4d12e944ea
15
shell/ash.c
15
shell/ash.c
@ -277,8 +277,10 @@ struct jmploc {
|
||||
};
|
||||
|
||||
struct globals_misc {
|
||||
/* pid of main shell */
|
||||
int rootpid;
|
||||
uint8_t exitstatus; /* exit status of last command */
|
||||
uint8_t back_exitstatus;/* exit status of backquoted command */
|
||||
smallint job_warning; /* user was warned about stopped jobs (can be 2, 1 or 0). */
|
||||
int rootpid; /* pid of main shell */
|
||||
/* shell level: 0 for the main shell, 1 for its children, and so on */
|
||||
int shlvl;
|
||||
#define rootshell (!shlvl)
|
||||
@ -355,10 +357,12 @@ struct globals_misc {
|
||||
random_t random_gen;
|
||||
#endif
|
||||
pid_t backgndpid; /* pid of last background process */
|
||||
smallint job_warning; /* user was warned about stopped jobs (can be 2, 1 or 0). */
|
||||
};
|
||||
extern struct globals_misc *const ash_ptr_to_globals_misc;
|
||||
#define G_misc (*ash_ptr_to_globals_misc)
|
||||
#define exitstatus (G_misc.exitstatus )
|
||||
#define back_exitstatus (G_misc.back_exitstatus )
|
||||
#define job_warning (G_misc.job_warning)
|
||||
#define rootpid (G_misc.rootpid )
|
||||
#define shlvl (G_misc.shlvl )
|
||||
#define minusc (G_misc.minusc )
|
||||
@ -380,7 +384,6 @@ extern struct globals_misc *const ash_ptr_to_globals_misc;
|
||||
#define trap_ptr (G_misc.trap_ptr )
|
||||
#define random_gen (G_misc.random_gen )
|
||||
#define backgndpid (G_misc.backgndpid )
|
||||
#define job_warning (G_misc.job_warning)
|
||||
#define INIT_G_misc() do { \
|
||||
(*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \
|
||||
barrier(); \
|
||||
@ -498,6 +501,8 @@ raise_interrupt(void)
|
||||
}
|
||||
ex_type = EXINT;
|
||||
}
|
||||
/* bash: ^C even on empty command line sets $? */
|
||||
exitstatus = SIGINT + 128;
|
||||
raise_exception(ex_type);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
@ -1217,7 +1222,6 @@ static struct parsefile *g_parsefile = &basepf; /* current input file */
|
||||
static int startlinno; /* line # where last token started */
|
||||
static char *commandname; /* currently executing command */
|
||||
static struct strlist *cmdenviron; /* environment for builtin command */
|
||||
static uint8_t exitstatus; /* exit status of last command */
|
||||
|
||||
|
||||
/* ============ Message printing */
|
||||
@ -5877,7 +5881,6 @@ struct backcmd { /* result of evalbackcmd */
|
||||
};
|
||||
|
||||
/* These forward decls are needed to use "eval" code for backticks handling: */
|
||||
static uint8_t back_exitstatus; /* exit status of backquoted command */
|
||||
#define EV_EXIT 01 /* exit after evaluating tree */
|
||||
static int evaltree(union node *, int);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user