-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
awscli2 ignores SIGTSTP, breaks shell job control (only from pyinstaller) #5478
Comments
Hi @salewski, Thanks for the detailed report. I'm able to I'm unable to reproduce the scenario mentioned for output of a service call too:
I ran For your comment at [0], the |
Hi @kdaily, Thanks for your response.
Encouraged by what you wrote, I sanity-checked my setup and the above issue report with "fresh" terminal windows (and a "fresh" head :-) but still see the issue as described. I then downloaded the latest
Unfortnately I still see the issue with this new version, too. And just to help rule out something with my particular xterm setup, I tried the test with other terminal emulators, too ( |
Hi @kdaily, I found that the problem is somehow related to the binary I will note, though, that my "normal" and historical use The rest of this comment is just details for future reference; just recording it here to track my evolving understanding. I built the tip of the
[
[Process is now correctly suspended, and I can type in the I then built the pyinstaller-based executable:
I then did the following to unpack the zip file and install it in-tree beneath the
When I run the ELF version of the Here's our ELF 'aws help' command before hitting
Here's
[ strace shows our
And
|
Looks like this issue might be due to pyinstaller issue #4057, fixed in PR #4244 (merged on 2020-05-02), and included in the project's 4.0 release on 2020-08-08. |
I've confirmed that the following trivial patch to use $ git diff requirements-build.txt
diff --git a/requirements-build.txt b/requirements-build.txt
index 5a2d6c82d..7020bb0fd 100644
--- a/requirements-build.txt
+++ b/requirements-build.txt
@@ -2,4 +2,4 @@
# We create the separation for cases where we're doing installation
# from a local dependency directory instead of requirements.txt.
cryptography==2.8
-PyInstaller==3.5
+PyInstaller==4.0 I'm not submitting a pull request for that change, though, because the resulting ELF binary can no longer be launched via a symlink:
It works fine if you use the real path (either relative or absolute):
That issue looks like A workaround for now is to avoid the |
Just want to note that there has been movement on that |
Hi @kdaily, I no longer see the issue. I tested both the nightly built artifact from https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip: $ /path/to/awscli2-2021-03-29_205242/bin/aws --version
aws-cli/2.1.32 Python/3.8.8 Linux/4.19.0-9-amd64 exe/x86_64.debian.10 prompt/off and with a version I built from source: $ ./dist/tttt/INSTALLED/v2/current/dist/aws --version
aws-cli/2.1.32 Python/3.9.1+ Linux/4.19.0-9-amd64 exe/x86_64.debian.10 prompt/off In both cases, suspending (CTRL-Z) and resuming the ELF binary (pyinstaller) version of the awscli2 program now "Just Works" for me. I also used Thank you to the @pyinstaller folks for the upstream fix, and to the @aws |
|
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
The
aws
command from awscli2 seems to be ignoring theSIGTSTP
signal. Thisviolates the user's expectation when working interactively in the shell because
the process cannot be easily suspended (CTRL-Z) and resumed. Effectively, this
behavior breaks job control.
This is a regression from the awscli version 1 behavior, which works with
standard Unix job control.
SDK version number
This is using the awscli2 program downloaded on
2020-08-13
from:Platform/OS/Hardware/Device
What are you running the cli on?
To Reproduce (observed behavior)
You'll need two terminal emulator windows. The first ("window A" below) is for
normal user activity; the second ("window B" below) is to see what is happening
and to allow us to easily "rescue" the first window when it inevitably hangs.
There are four steps, but only the first two are needed to reproduce the issue.
SIGSTOP
SIGCONT
Steps 3 and 4 describe ways of dealing with the issue once encountered, and give
us an opportunity to show some additional detail.
Step 1 of 4 - setup
In window A, we note our terminal and then just run 'aws help'. That lands the
user in the pager (
less
).In window B, use the
ps
command take a look at the process tree from window A.So far, so good. No problems yet.
Note that the plus (
+
) signs in theSTAT
column indicate that theaws help
process (and friends) are in the foreground process group:
Step 2 of 4 - hang terminal window A
In window A, press
CTRL-Z
to suspend the process; the terminal session will beeffectively hung:
In window B, again use
ps
to look at the process tree from window A. This timewe can see that only two of the three processes involved have been stopped (as
indicated by the
T
for them in theSTAT
column). The plus (+
) signs in theSTAT
column tell us that theaws help
process (and friends) are still in theforeground process group. The process group is "half suspended":
Step 3 of 4 (optional) - rescue with
SIGSTOP
We can force the
aws
process to stop by sending it aSIGSTOP
signal (recallthat
SIGSTOP
cannot be caught):You can see that the
aws
process (and friends) are no longer in the foregroundprocess group. The single
+
in theSTAT
column shows that the parent shell(
bash
) is back in control.Furthermore, the shell in window A is again usable:
Step 4 of 4 (optional) - rescue with
SIGCONT
In window A, bring the suspended
aws help
process group back into theforeground. This will resume the pager. Press
CTRL-Z
to again hang theterminal:
In window B, confirm the state looks like the hung scenario described above:
Now rather than send
SIGSTOP
to force the process group to suspend, insteadsend two
SIGCONT
signals to the already-stopped processes to resume them:And again confirm the state of the process tree. We can see that the entire
aws help
process group is again in the foreground; it is no longer in a "half suspended" state:
At this point, the pager in window A is again usable. You can type 'q' to exit
out of 'less' and otherwise continue using the terminal window.
Expected behavior
Standard Unix job control could be used with
aws
(awscli2).Pressing
CTRL-Z
while reading the docs would put theaws help/pager
processgroup into the background and return control to the shell. The use would be able
to jump back into the pager using the standard Unix job control features of the
shell.
Logs/output
Nothing much relevant. All logging precedes the triggering of the hung behavior,
and no additional log messages are recorded beyond that point when performing
the above steps. But FWIW, below are some snippets as captured by running:
The top and bottom of the debug log:
Additional context
Empirical testing suggests there are actually two different flavors of this
issue: one that affects
aws help
output, and one that affects the output AWSAPI service calls.
The former is what is described above, and is "the worse" of the two both
because a) it is the more common use case (for the author) for using
aws
withjob control;
and b) there is no easy workaround for it.[UPDATE (2020-08-20): There is a workaround: build from the git 'v2'
branch and invoke the
aws
python script directly; avoid invoking theaws
binary executable from the
pyinstaller
-created installer. See commentsbelow, especially this one.]
The second has a workaround, which is to use the pager to consume all of the
service output data before attempting to suspend the pager. While clumsy, this
workaround can be performed "inline" in the shell session; it can be applied
without the need to open additional terminal windows and go hunting for PIDs to
which we would then send signals (as described above).
Note that for the second flavor the bug works differently depending on the
cli_pager
setting[0]. With the default settings it will beaws
thatlaunches
less
, and when that is the case the "consume all data beforesuspending" workaround does not apply. Even after consuming all of the data, the
aws
process will go into the "half suspended" state if you pressCTRL-Z
inthe pager.
[0] For the above tests, the
--no-paginate
command line option is notequivalent to setting the
cli_pager
option to an empty value in~/.aws/config
. That seems like a different bug, though.With
cli_pager
set to an empty value, it would be the user piping the outputof the
aws
toless
. Theless
invocation is part of the same process group,so is still susceptible to hanging the terminal. But in this arrangement, having
the pager consume all of the output data from the AWS service call allows the
aws
command to exit. When that happens, the only process left in theforeground process group will be the pager; at that point job control will work
as expected. The user can suspend the pager, resume it, etc.
Step 1 of 3 - disable paging of service data output
In
~/.aws.config
, add this setting to the relevant profile:Step 2 of 3 - pipe data to pager
In terminal window A, invoke a command that triggers an AWS API service call
and emits a decent amount of data (enough for multiple pages in your pager
app). Here we happen to be using
iam list-policies
for that purpose:In window B, use
ps
to look at the state of the process tree from window A:So far, so good. Note that
less
is a direct descendant of the shell (bash
)rather than of the
aws
command.Note: If you were to press
CTRL-Z
at this point, then window A wouldeffectively be hung as described above. Don't do that here.
Step 3 of 3 - use pager to slurp-up all data
In window A, tell your pager to "jump to the end". This will have the effect of
consuming all of the data from the AWS API service call, as emitted by the
aws
command. In
less
, this can be done by issuing the command0G
(zerocapital-gee).
In window B, again look at the process tree:
Notice that the
aws
process has completed its work and exited. The onlyprocess still in the foreground process group is the pager. At this point, you
can suspend the pager (
CTRL-Z
) and it will work as expected; it will nothang the terminal.
The text was updated successfully, but these errors were encountered: