Compare commits
11
Commits
master
...
1_32_stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbd3b883a8 | ||
|
|
30ffa2bb15 | ||
|
|
d811a8cd01 | ||
|
|
71afe6c513 | ||
|
|
0f668aad7f | ||
|
|
06f7cf1487 | ||
|
|
58cbf385e0 | ||
|
|
e7629ffbf5 | ||
|
|
e4c7cf3f8c | ||
|
|
4ac4f60942 | ||
|
|
94f6d1ece0 |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 32
|
||||
SUBLEVEL = 0
|
||||
SUBLEVEL = 1
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
|
||||
@@ -220,10 +220,20 @@ static const uint8_t border[] ALIGN1 = {
|
||||
* each table.
|
||||
* t: table to free
|
||||
*/
|
||||
#define BAD_HUFT(p) ((uintptr_t)(p) & 1)
|
||||
#define ERR_RET ((huft_t*)(uintptr_t)1)
|
||||
static void huft_free(huft_t *p)
|
||||
{
|
||||
huft_t *q;
|
||||
|
||||
/*
|
||||
* If 'p' has the error bit set we have to clear it, otherwise we might run
|
||||
* into a segmentation fault or an invalid pointer to free(p)
|
||||
*/
|
||||
if (BAD_HUFT(p)) {
|
||||
p = (huft_t*)((uintptr_t)(p) ^ (uintptr_t)(ERR_RET));
|
||||
}
|
||||
|
||||
/* Go through linked list, freeing from the malloced (t[-1]) address. */
|
||||
while (p) {
|
||||
q = (--p)->v.t;
|
||||
@@ -289,8 +299,6 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
|
||||
* or a valid pointer to a Huffman table, ORed with 0x1 if incompete table
|
||||
* is given: "fixed inflate" decoder feeds us such data.
|
||||
*/
|
||||
#define BAD_HUFT(p) ((uintptr_t)(p) & 1)
|
||||
#define ERR_RET ((huft_t*)(uintptr_t)1)
|
||||
static huft_t* huft_build(const unsigned *b, const unsigned n,
|
||||
const unsigned s, const struct cp_ext *cp_ext,
|
||||
unsigned *m)
|
||||
|
||||
+60
-69
@@ -4273,50 +4273,6 @@ sprint_status48(char *os, int status, int sigonly)
|
||||
return s - os;
|
||||
}
|
||||
|
||||
static int
|
||||
wait_block_or_sig(int *status)
|
||||
{
|
||||
int pid;
|
||||
|
||||
do {
|
||||
sigset_t mask;
|
||||
|
||||
/* Poll all children for changes in their state */
|
||||
got_sigchld = 0;
|
||||
/* if job control is active, accept stopped processes too */
|
||||
pid = waitpid(-1, status, doing_jobctl ? (WNOHANG|WUNTRACED) : WNOHANG);
|
||||
if (pid != 0)
|
||||
break; /* Error (e.g. EINTR, ECHILD) or pid */
|
||||
|
||||
/* Children exist, but none are ready. Sleep until interesting signal */
|
||||
#if 1
|
||||
sigfillset(&mask);
|
||||
sigprocmask2(SIG_SETMASK, &mask); /* mask is updated */
|
||||
while (!got_sigchld && !pending_sig) {
|
||||
sigsuspend(&mask);
|
||||
/* ^^^ add "sigdelset(&mask, SIGCHLD);" before sigsuspend
|
||||
* to make sure SIGCHLD is not masked off?
|
||||
* It was reported that this:
|
||||
* fn() { : | return; }
|
||||
* shopt -s lastpipe
|
||||
* fn
|
||||
* exec ash SCRIPT
|
||||
* under bash 4.4.23 runs SCRIPT with SIGCHLD masked,
|
||||
* making "wait" commands in SCRIPT block forever.
|
||||
*/
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, &mask, NULL);
|
||||
#else /* unsafe: a signal can set pending_sig after check, but before pause() */
|
||||
while (!got_sigchld && !pending_sig)
|
||||
pause();
|
||||
#endif
|
||||
|
||||
/* If it was SIGCHLD, poll children again */
|
||||
} while (got_sigchld);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
#define DOWAIT_NONBLOCK 0
|
||||
#define DOWAIT_BLOCK 1
|
||||
#define DOWAIT_BLOCK_OR_SIG 2
|
||||
@@ -4324,13 +4280,48 @@ wait_block_or_sig(int *status)
|
||||
# define DOWAIT_JOBSTATUS 0x10 /* OR this to get job's exitstatus instead of pid */
|
||||
#endif
|
||||
|
||||
static int
|
||||
waitproc(int block, int *status)
|
||||
{
|
||||
sigset_t oldmask;
|
||||
int flags = block == DOWAIT_BLOCK ? 0 : WNOHANG;
|
||||
int err;
|
||||
|
||||
#if JOBS
|
||||
if (doing_jobctl)
|
||||
flags |= WUNTRACED;
|
||||
#endif
|
||||
|
||||
do {
|
||||
got_sigchld = 0;
|
||||
do
|
||||
err = waitpid(-1, status, flags);
|
||||
while (err < 0 && errno == EINTR);
|
||||
|
||||
if (err || (err = -!block))
|
||||
break;
|
||||
|
||||
sigfillset(&oldmask);
|
||||
sigprocmask2(SIG_SETMASK, &oldmask); /* mask is updated */
|
||||
while (!got_sigchld && !pending_sig)
|
||||
sigsuspend(&oldmask);
|
||||
sigprocmask(SIG_SETMASK, &oldmask, NULL);
|
||||
//simpler, but unsafe: a signal can set pending_sig after check, but before pause():
|
||||
//while (!got_sigchld && !pending_sig)
|
||||
// pause();
|
||||
|
||||
} while (got_sigchld);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
waitone(int block, struct job *job)
|
||||
{
|
||||
int pid;
|
||||
int status;
|
||||
struct job *jp;
|
||||
struct job *thisjob;
|
||||
struct job *thisjob = NULL;
|
||||
#if BASH_WAIT_N
|
||||
bool want_jobexitstatus = (block & DOWAIT_JOBSTATUS);
|
||||
block = (block & ~DOWAIT_JOBSTATUS);
|
||||
@@ -4357,21 +4348,8 @@ waitone(int block, struct job *job)
|
||||
* SIG_DFL handler does not wake sigsuspend().
|
||||
*/
|
||||
INT_OFF;
|
||||
if (block == DOWAIT_BLOCK_OR_SIG) {
|
||||
pid = wait_block_or_sig(&status);
|
||||
} else {
|
||||
int wait_flags = 0;
|
||||
if (block == DOWAIT_NONBLOCK)
|
||||
wait_flags = WNOHANG;
|
||||
/* if job control is active, accept stopped processes too */
|
||||
if (doing_jobctl)
|
||||
wait_flags |= WUNTRACED;
|
||||
/* NB: _not_ safe_waitpid, we need to detect EINTR */
|
||||
pid = waitpid(-1, &status, wait_flags);
|
||||
}
|
||||
TRACE(("wait returns pid=%d, status=0x%x, errno=%d(%s)\n",
|
||||
pid, status, errno, strerror(errno)));
|
||||
thisjob = NULL;
|
||||
pid = waitproc(block, &status);
|
||||
TRACE(("wait returns pid %d, status=%d\n", pid, status));
|
||||
if (pid <= 0)
|
||||
goto out;
|
||||
|
||||
@@ -4453,15 +4431,27 @@ waitone(int block, struct job *job)
|
||||
static int
|
||||
dowait(int block, struct job *jp)
|
||||
{
|
||||
int pid = block == DOWAIT_NONBLOCK ? got_sigchld : 1;
|
||||
smallint gotchld = *(volatile smallint *)&got_sigchld;
|
||||
int rpid;
|
||||
int pid;
|
||||
|
||||
while (jp ? jp->state == JOBRUNNING : pid > 0) {
|
||||
if (!jp)
|
||||
got_sigchld = 0;
|
||||
if (jp && jp->state != JOBRUNNING)
|
||||
block = DOWAIT_NONBLOCK;
|
||||
|
||||
if (block == DOWAIT_NONBLOCK && !gotchld)
|
||||
return 1;
|
||||
|
||||
rpid = 1;
|
||||
|
||||
do {
|
||||
pid = waitone(block, jp);
|
||||
}
|
||||
rpid &= !!pid;
|
||||
|
||||
return pid;
|
||||
if (!pid || (jp && jp->state != JOBRUNNING))
|
||||
block = DOWAIT_NONBLOCK;
|
||||
} while (pid >= 0);
|
||||
|
||||
return rpid;
|
||||
}
|
||||
|
||||
#if JOBS
|
||||
@@ -4708,7 +4698,7 @@ waitcmd(int argc UNUSED_PARAM, char **argv)
|
||||
job = getjob(*argv, 0);
|
||||
}
|
||||
/* loop until process terminated or stopped */
|
||||
dowait(DOWAIT_BLOCK_OR_SIG, NULL);
|
||||
dowait(DOWAIT_BLOCK_OR_SIG, job);
|
||||
if (pending_sig)
|
||||
goto sigout;
|
||||
job->waited = 1;
|
||||
@@ -7021,7 +7011,8 @@ subevalvar(char *start, char *str, int strloc,
|
||||
slash_pos = -1;
|
||||
if (repl) {
|
||||
slash_pos = expdest - ((char *)stackblock() + strloc);
|
||||
STPUTC('/', expdest);
|
||||
if (!(flag & EXP_DISCARD))
|
||||
STPUTC('/', expdest);
|
||||
//bb_error_msg("repl+1:'%s'", repl + 1);
|
||||
p = argstr(repl + 1, (flag & EXP_DISCARD) | EXP_TILDE); /* EXP_TILDE: echo "${v/x/~}" expands ~ ! */
|
||||
*repl = '/';
|
||||
@@ -12811,7 +12802,7 @@ parsebackq: {
|
||||
goto done;
|
||||
|
||||
case '\\':
|
||||
pc = pgetc(); /* or pgetc_eatbnl()? why (example)? */
|
||||
pc = pgetc(); /* not pgetc_eatbnl! */
|
||||
if (pc != '\\' && pc != '`' && pc != '$'
|
||||
&& (!synstack->dblquote || pc != '"')
|
||||
) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Background1
|
||||
Ok:0
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
sleep 1 && echo "Background1" &
|
||||
pid=$!
|
||||
sleep 3 && echo "Background2: BUG!" &
|
||||
# Shouldn't wait for 2nd bkgd:
|
||||
wait $pid
|
||||
kill $!
|
||||
echo Ok:$?
|
||||
@@ -0,0 +1 @@
|
||||
test
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
printf 'test\0zest\n' | (read -d '' reply; echo "$reply")
|
||||
@@ -0,0 +1,14 @@
|
||||
___
|
||||
___
|
||||
___
|
||||
trap -- 'a' EXIT
|
||||
trap -- 'a' INT
|
||||
trap -- 'a' USR1
|
||||
trap -- 'a' USR2
|
||||
___
|
||||
___
|
||||
trap -- 'a' USR1
|
||||
trap -- 'a' USR2
|
||||
___
|
||||
___
|
||||
trap -- 'a' USR2
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
# no output -- default state
|
||||
echo ___
|
||||
trap
|
||||
|
||||
# assign some traps
|
||||
echo ___
|
||||
trap "a" EXIT INT USR1 USR2
|
||||
|
||||
# show them all
|
||||
echo ___
|
||||
trap
|
||||
|
||||
# clear one
|
||||
echo ___
|
||||
trap 0 INT
|
||||
echo ___
|
||||
trap
|
||||
|
||||
# clear another
|
||||
echo ___
|
||||
trap "-" USR1
|
||||
echo ___
|
||||
trap
|
||||
@@ -1,2 +1,3 @@
|
||||
|
||||
|
||||
Ok:0
|
||||
@@ -1,3 +1,5 @@
|
||||
unset v
|
||||
echo ${v/*/w}
|
||||
v=''
|
||||
echo ${v/*/w}
|
||||
echo Ok:$?
|
||||
+9
-3
@@ -8698,9 +8698,15 @@ static int process_wait_result(struct pipe *fg_pipe, pid_t childpid, int status)
|
||||
*/
|
||||
if (WIFSIGNALED(status)) {
|
||||
int sig = WTERMSIG(status);
|
||||
if (i == fg_pipe->num_cmds-1)
|
||||
/* TODO: use strsignal() instead for bash compat? but that's bloat... */
|
||||
puts(sig == SIGINT || sig == SIGPIPE ? "" : get_signame(sig));
|
||||
if (G.run_list_level == 1
|
||||
/* ^^^^^ Do not print in nested contexts, example:
|
||||
* echo `sleep 1; sh -c 'kill -9 $$'` - prints "137", NOT "Killed 137"
|
||||
*/
|
||||
&& i == fg_pipe->num_cmds-1
|
||||
) {
|
||||
/* strsignal() is for bash compat. ~600 bloat versus bbox's get_signame() */
|
||||
puts(sig == SIGINT || sig == SIGPIPE ? "" : strsignal(sig));
|
||||
}
|
||||
/* TODO: if (WCOREDUMP(status)) + " (core dumped)"; */
|
||||
/* TODO: MIPS has 128 sigs (1..128), what if sig==128 here?
|
||||
* Maybe we need to use sig | 128? */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
KILL
|
||||
Killed
|
||||
137:137
|
||||
KILL
|
||||
Killed
|
||||
0:0
|
||||
Done
|
||||
@@ -0,0 +1,2 @@
|
||||
Background1
|
||||
Ok:0
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
sleep 1 && echo "Background1" &
|
||||
pid=$!
|
||||
sleep 3 && echo "Background2: BUG!" &
|
||||
# Shouldn't wait for 2nd bkgd:
|
||||
wait $pid
|
||||
kill $!
|
||||
echo Ok:$?
|
||||
@@ -0,0 +1 @@
|
||||
137
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
true; echo `sh -c 'kill -9 $$'` $?
|
||||
@@ -0,0 +1 @@
|
||||
test
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
printf 'test\0zest\n' | (read -d '' reply; echo "$reply")
|
||||
@@ -2,4 +2,4 @@ sending USR2
|
||||
caught
|
||||
sending USR2
|
||||
sending USR2
|
||||
USR2
|
||||
User defined signal 2
|
||||
@@ -0,0 +1,20 @@
|
||||
got signal
|
||||
trap -- 'echo got signal' USR1
|
||||
sent 1 signal
|
||||
got signal
|
||||
wait interrupted
|
||||
trap -- 'echo got signal' USR1
|
||||
sent 2 signal
|
||||
got signal
|
||||
wait interrupted
|
||||
trap -- 'echo got signal' USR1
|
||||
sent 3 signal
|
||||
got signal
|
||||
wait interrupted
|
||||
trap -- 'echo got signal' USR1
|
||||
sent 4 signal
|
||||
got signal
|
||||
wait interrupted
|
||||
trap -- 'echo got signal' USR1
|
||||
sent 5 signal
|
||||
sleep completed
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
trap "echo got signal" USR1
|
||||
|
||||
for try in 1 2 3 4 5; do
|
||||
kill -USR1 $$
|
||||
sleep 0.2
|
||||
echo "sent $try signal"
|
||||
done &
|
||||
|
||||
# Ensure "wait" has something to wait for
|
||||
sleep 2 &
|
||||
|
||||
# Ensure we do not execute "trap" below before "kill -USR1" above
|
||||
# (was getting failure on loaded machine without this)
|
||||
sleep 0.1
|
||||
|
||||
sleeping=true
|
||||
while $sleeping; do
|
||||
trap
|
||||
if wait %%; then
|
||||
echo "sleep completed"
|
||||
sleeping=false
|
||||
elif [ $? = 127 ]; then
|
||||
echo "BUG: no processes to wait for?!"
|
||||
sleeping=false
|
||||
else
|
||||
echo "wait interrupted"
|
||||
fi
|
||||
done
|
||||
@@ -1,2 +1,2 @@
|
||||
HUP
|
||||
Hangup
|
||||
Done:129
|
||||
@@ -17,5 +17,5 @@ Ok
|
||||
trap -- '' HUP
|
||||
trap -- '' QUIT
|
||||
trap -- '' SYS
|
||||
TERM
|
||||
Terminated
|
||||
Done
|
||||
+2
-2
@@ -251,7 +251,7 @@ typedef struct remembered_name {
|
||||
} remembered_name;
|
||||
|
||||
|
||||
static arith_t FAST_FUNC
|
||||
static arith_t
|
||||
evaluate_string(arith_state_t *math_state, const char *expr);
|
||||
|
||||
static const char*
|
||||
@@ -582,7 +582,7 @@ static arith_t strto_arith_t(const char *nptr, char **endptr)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static arith_t FAST_FUNC
|
||||
static arith_t
|
||||
evaluate_string(arith_state_t *math_state, const char *expr)
|
||||
{
|
||||
operator lasttok;
|
||||
|
||||
@@ -209,8 +209,6 @@ shell_builtin_read(struct builtin_read_params *params)
|
||||
}
|
||||
|
||||
c = buffer[bufpos];
|
||||
if (c == '\0')
|
||||
continue;
|
||||
if (!(read_flags & BUILTIN_READ_RAW)) {
|
||||
if (backslash) {
|
||||
backslash = 0;
|
||||
@@ -225,6 +223,8 @@ shell_builtin_read(struct builtin_read_params *params)
|
||||
}
|
||||
if (c == delim) /* '\n' or -d CHAR */
|
||||
break;
|
||||
if (c == '\0')
|
||||
continue;
|
||||
|
||||
/* $IFS splitting. NOT done if we run "read"
|
||||
* without variable names (bash compat).
|
||||
|
||||
Reference in new issue
Block a user