Skip to content
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

resume (fg) from suspend (^Z) doesn't work inside a shell script #889

Open
2 of 3 tasks
nbuwe opened this issue May 29, 2024 · 1 comment
Open
2 of 3 tasks

resume (fg) from suspend (^Z) doesn't work inside a shell script #889

nbuwe opened this issue May 29, 2024 · 1 comment

Comments

@nbuwe
Copy link

nbuwe commented May 29, 2024

Description:

If an urwid app is started from a shell script wrapper and is suspended with ^Z, when you try to resume the script/app with fg, the shell script wrapper is resumed, but the urwid app is still in the stopped state.

Affected versions (if applicable)
  • master branch (specify commit)
  • Latest stable version from pypi
  • Other (specify source)

Seems to have been broken between 2.1.2 and 2.2.0

Steps to reproduce (if applicable)
$ python -m venv ~/.local/urwid
$ PATH=$HOME/.local/urwid/bin:$PATH
$ pip install urwid
$ cd examples
$ python browse.py
^Z
$ fg
... works ...

but

$ echo 'python "$@"' > runme.sh
$ sh runme.sh browse.py
^Z
$ fg
... no display ...

You can check the process state from another terminal, and the python process will be in the stopped state.

At this stage you can ^Z and fg it again, and it will get resumed the second time round.

Expected/actual outcome

fg resumes an urwid app launched from a wrapper script every time, not every other time.

@nbuwe nbuwe added the bug label May 29, 2024
@nbuwe
Copy link
Author

nbuwe commented May 31, 2024

So what seems to happen is that trying to do some terminal ioctls causes the python process to receive SIGTTOU, that stops the process while it's still inside the SIGTSTP handler. Then the process is resumed while still in the sigtstp handler, where it happily re-sends SIGTSTP to itself and gets stopped again.

When the process is suspended and resumed the second time, the normal SIGCONT handler runs and everything is fine.

@penguinolog penguinolog pinned this issue Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants