| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
sig_unblock 41 43 +2
sig_block 41 40 -1
sigprocmask_allsigs 33 31 -2
wait_for_child_or_signal 202 193 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 2/-12) Total: -10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
text data bss dec hex filename
1067871 559 5184 1073614 1061ce busybox_old
1068067 555 5088 1073710 10622e busybox_unstripped
^^^^^^^^^^^
function old new delta
pgetc 580 623 +43
parse_command 1633 1651 +18
ash_main 1226 1239 +13
popstring 115 126 +11
redirect 951 961 +10
popfile 105 115 +10
expandstr 252 262 +10
evalbltin 306 314 +8
pushstring 155 162 +7
pushfile 31 38 +7
freestrings 90 97 +7
setinputstring 68 74 +6
readtoken1 3095 3101 +6
pungetc 9 15 +6
nlprompt 39 45 +6
nlnoprompt 33 39 +6
unwindfiles 20 25 +5
dotcmd 309 314 +5
setinputfile 190 194 +4
init 429 432 +3
forkchild 617 620 +3
evalcommand 1616 1617 +1
ash_vmsg 141 142 +1
g_parsefile 4 - -4
commandname 4 - -4
basepf 84 - -84
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 23/0 up/down: 196/-92) Total: 104 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Upstream commit:
Date: Thu, 28 May 2020 21:31:45 +1000
redir: Retry open64 on EINTR
It is possible for open64 to block on named pipes, and therefore
it can be interrupted by signals and return EINTR. We should only
let it fail with EINTR if real signals are pending (i.e., it should
not fail on SIGCHLD if SIGCHLD has not been trapped).
This patch adds a new helper sh_open to retry the open64 call if
necessary. It also calls sh_error when appropriate.
Fixes: 3800d4934391 ("[JOBS] Fix dowait signal race")
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Upstream commit:
Date: Sun, 3 Mar 2019 21:57:50 +0800
eval: Reset handler when entering a subshell
As it is a subshell can execute code that is only meant for the
parent shell when it executes a longjmp that is caught by something
like evalcommand. This patch fixes it by resetting the handler
when entering a subshell.
function old new delta
evalsubshell 169 183 +14
evalpipe 342 356 +14
argstr 1406 1416 +10
ash_main 1236 1226 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 65/-10) Total: 28 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Upstream commit:
Date: Wed, 6 Jan 2021 15:45:12 +1100
jobs: Block signals during tcsetpgrp
Harald van Dijk <harald@gigawatt.nl> wrote:
> On 19/12/2020 22:21, Steffen Nurpmeso wrote:
>> Steffen Nurpmeso wrote in
>> <20201219172838.1B-WB%steffen@sdaoden.eu>:
>> |Long story short, after falsely accusing BSD make of not working
>>
>> After dinner i shortened it a bit more, and attach it again, ok?
>> It is terrible, but now less redundant than before.
>> Sorry for being so terse, that problem crosses my head for about
>> a week, and i was totally mislead and if you bang your head
>> against the wall so many hours bugs or misbehaviours in a handful
>> of other programs is not the expected outcome.
>
> I think a minimal test case is simply
>
> all:
> $(SHELL) -c 'trap "echo TTOU" TTOU; set -m; echo all good'
>
> unless I accidentally oversimplified.
>
> The SIGTTOU is caused by setjobctl's xtcsetpgrp(fd, pgrp) call to make
> its newly started process group the foreground process group when job
> control is enabled, where xtcsetpgrp is a wrapper for tcsetpgrp. (That's
> in dash, the other variants may have some small differences.) tcsetpgrp
> has this little bit in its specification:
>
> Attempts to use tcsetpgrp() from a process which is a member of
> a background process group on a fildes associated with its con‐
> trolling terminal shall cause the process group to be sent a
> SIGTTOU signal. If the calling thread is blocking SIGTTOU sig‐
> nals or the process is ignoring SIGTTOU signals, the process
> shall be allowed to perform the operation, and no signal is
> sent.
>
> Ordinarily, when job control is enabled, SIGTTOU is ignored. However,
> when a trap action is specified for SIGTTOU, the signal is not ignored,
> and there is no blocking in place either, so the tcsetpgrp() call is not
> allowed.
>
> The lowest impact change to make here, the one that otherwise preserves
> the existing shell behaviour, is to block signals before calling
> tcsetpgrp and unblocking them afterwards. This ensures SIGTTOU does not
> get raised here, but also ensures that if SIGTTOU is sent to the shell
> for another reason, there is no window where it gets silently ignored.
>
> Another way to fix this is by not trying to make the shell start a new
> process group, or at least not make it the foreground process group.
> Most other shells appear to not try to do this.
This patch implements the blocking of SIGTTOU (and everything else)
while we call tcsetpgrp.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Upstream commit:
Date: Sat, 19 May 2018 02:39:56 +0800
eval: Add vfork support
This patch adds basic vfork support for the case of a simple command.
Upstream commit:
Date: Tue, 12 Jan 2021 17:11:19 +1100
jobs: Always reset SIGINT/SIGQUIT handlers
On Fri, Jan 08, 2021 at 08:55:41PM +0000, Harald van Dijk wrote:
> On 18/05/2018 19:39, Herbert Xu wrote:
> > This patch adds basic vfork support for the case of a simple command.
> > ... @@ -879,17 +892,30 @@ forkchild(struct job *jp, union node *n, int
> > mode)
> > }
> > }
> > if (!oldlvl && iflag) {
> > - setsignal(SIGINT);
> > - setsignal(SIGQUIT);
> > + if (mode != FORK_BG) {
> > + setsignal(SIGINT);
> > + setsignal(SIGQUIT);
> > + }
> > setsignal(SIGTERM);
> > }
> > +
> > + if (lvforked)
> > + return;
> > +
> > for (jp = curjob; jp; jp = jp->prev_job)
> > freejob(jp);
> > }
>
> This leaves SIGQUIT ignored in background jobs in interactive shells.
>
> ENV= dash -ic 'dash -c "kill -QUIT \$\$; echo huh" & wait'
>
> As of dash 0.5.11, this prints "huh". Before, the subprocess process killed
> itself before it could print anything. Other shells do not leave SIGQUIT
> ignored.
>
> (In a few other shells, this also prints "huh", but in those other shells,
> that is because the inner shell chooses to ignore SIGQUIT, not because the
> outer shell leaves it ignored.)
Thanks for catching this. I have no idea how that got in there
and it makes no sense whatsoever. This patch removes the if
conditional.
Fixes: e94a964e7dd0 ("eval: Add vfork support")
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
Comparing code with dash is more difficult with these differences.
(We didn't know back then that dash will be revived...)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
Apply upstream commit f6fb3c603. This moves some static data into
globals_misc. The Windows port had already moved commandname, so
only g_parsefile and basepf are new. Some changes had to be made
to the forkshell code.
Adds 148-176 bytes.
|
| | | |
|
| | |
| |
| |
| |
| |
| | |
Apply upstream commit 9b67dde8c.
Adds 8 bytes in the 32-bit build.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Apply upstream commit 81274d8b3.
On Windows it isn't necessary to reset the exception handler in
evalbackcmd() or evalpipe(), as that will have been done by
forkshell_init().
The globals_misc structure now contains a setjmp() buffer. On
64-bit Windows this needs 16-byte alignment. This is achieved
in the forkshell data structure by placing the globals_misc
data immediately after the 16-byte aligned forkshell data.
Saves 144 bytes in the 64-bit build.
|
| | |
| |
| |
| | |
Merge upstream commit 4ce8afe6b. This has no effect on Windows.
|
| | |
| |
| |
| |
| |
| |
| | |
Merge upstream commit df154028d. Since we don't have vfork() on
Windows we continue to use the spawn_forkshell() mechanism.
Although there is some rearrangement of the code it's functionally
the same.
|
| | |
| |
| |
| |
| | |
Merge upstream commit 9f490785e. The changes are cosmetic, to
bring the code into line with dash.
|
| |\| |
|
| | |
| |
| |
| |
| |
| | |
Testsuite reports lots of message mismatches, fix that
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Upstream commit:
Date: Tue, 6 Dec 2022 16:49:14 +0800
eval: Always set exitstatus in evaltree
There is no harm in setting exitstatus unconditionally in evaltree.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Upstream commit:
Date: Mon Feb 25 12:49:20 2019 +0800
options: Do not set commandname in procargs
We set commandname in procargs when we don't have to. This results
in a duplicated output of arg0 when an error occurs.
function old new delta
ash_main 1256 1236 -20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
vstype_suffix - 39 +39
static.vstype 42 - -42
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/0 up/down: 39/-42) Total: -3 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
cmdputs 402 418 +16
static.vstype 48 42 -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-6) Total: 10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
o_save_ptr 176 167 -9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
readtoken1 3053 3095 +42
xxreadtoken 215 212 -3
expandstr 255 252 -3
parseheredoc 148 127 -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 42/-27) Total: 15 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
fetch_heredocs 477 485 +8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
glob_needed 71 86 +15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |\| |
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
generate_stream_from_string 222 232 +10
setup_heredoc 329 330 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 11/0) Total: 11 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
...and discover that we can do away with 1-3 initialization syscalls.
function old new delta
hush_main 1152 1146 -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Also, make second calls to install_special_sighandlers() less haphazard.
It's not a fix for anything, but looking more organized now.
function old new delta
fflush_restore_ttypgrp_and__exit - 20 +20
restore_ttypgrp_and__exit 21 - -21
hush_main 1181 1152 -29
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 20/-50) Total: -30 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| | |
restore_ttypgrp_and_killsig_or__exit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |\| |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
.rodata 105787 105823 +36
fetch_heredocs 461 477 +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 52/0) Total: 52 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |\| |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The rationale here is that unsetting HISTFILE in /etc/profile
does not "stick": if it's unset, the default one is set later
(after /etc/profile is executed) by the shell.
But setting (and exporting, so it is inherited by all
(grand)child shells) an empty one works.
function old new delta
save_history 296 316 +20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
"HISTFILESIZE=0" in profile wasn't working as intended,
"unset HISTFILE" wasn't preventing creation of history files
Now:
HISTSIZE=n allows to reduce in-memory history buffer
HISTFILESIZE=n allows to reduce history file size (0: truncate it)
unset HISTFILE allows to not save history file at all
function old new delta
exitshell 138 194 +56
hush_exit 97 143 +46
save_history 266 296 +30
hush_main 1170 1186 +16
.rodata 105762 105771 +9
load_history 246 254 +8
size_from_HISTFILESIZE 44 41 -3
read_line_input 2746 2712 -34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/2 up/down: 165/-37) Total: 128 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
__ppoll_time64 - 211 +211
check_got_signal_and_poll - 164 +164
read_key 607 601 -6
shell_builtin_read 1328 1318 -10
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 0/2 up/down: 375/-16) Total: 359 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Make the read built-in more compatible with bash:
- Return an exit code of 142 on timeout.
- When the timeout expires before a newline is detected in the
input bash captures the partial input. This behaviour is new
since bash version 4.4. BusyBox shells had the pre-4.4 behaviour
where the input was lost.
Update the tests to suit and fix a couple of compiler errors in
the testsuite.
function old new delta
builtin_read 154 174 +20
readcmd 213 228 +15
shell_builtin_read 1364 1370 +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0) Total: 41 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When the '-n' option was used to limit the number of characters
read, any backslashes in the input weren't correctly accounted
for.
Adds 16 bytes.
(GitHub issue #504)
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit e07a73a15 (ash: bring 'read' built-in closer to bash)
added code to treat a timeout differently from an error returned
by poll(2). This falsely assumed that only an EINTR error was
relevant. We must allow for other errors.
Adds 16 bytes.
(GitHub issue #502)
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Consider this script:
#!/bin/sh -e
f() {
for n in $(seq 1 10); do
echo "Background $n ..."
sleep 1
done
}
f 1 &
f 2 &
f 3 &
wait
If this was interrupted by Ctrl+C the background jobs continued to
run. Avoid this by sending SIGINT to all children of the shell.
Saves 16 bytes.
(See GitHub PR #500)
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 8e6991733 (ash: fix 'read' shell built-in (1)) noted
discrepancies between upstream BusyBox, busybox-w32 and bash.
It aligned busybox-w32 with upstream BusyBox. Apply further
changes in busybox-w32 to align 'read' more closely with bash.
- When a timeout occurs before a newline in the input stream,
capture and save the text collected so far.
- Return an exit code of 142 on timeout.
Also, since our implementation of poll(2) never sets errno to
EINTR the code to handle this case can be omitted.
Saves 16 bytes in the 64-bit build, adds 16 in 32-bit.
(GitHub issue #502)
|