[GH-ISSUE #613] Recording wont exit when using P10k's instant prompt #317

Closed
opened 2026-02-25 20:33:19 +03:00 by kerem · 20 comments
Owner

Originally created by @Pytness on GitHub (Feb 8, 2024).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/613

Describe the bug
asciinema rec wont terminate when exiting zsh shell if using p10k-instant-prompt.

To Reproduce
Steps to reproduce the behavior:

  1. ascinema rec -c "zsh"
  2. ...
  3. exit
  4. asciinema keeps recording

Expected behavior
Stop recording

Versions:

  • OS: Ubuntu 22.04
  • asciinema cli: asciinema 3.0.0-beta.2
Originally created by @Pytness on GitHub (Feb 8, 2024). Original GitHub issue: https://github.com/asciinema/asciinema/issues/613 **Describe the bug** asciinema rec wont terminate when exiting zsh shell if using p10k-instant-prompt. **To Reproduce** Steps to reproduce the behavior: 1. ascinema rec -c "zsh" 2. ... 3. exit 4. asciinema keeps recording **Expected behavior** Stop recording **Versions:** - OS: Ubuntu 22.04 - asciinema cli: asciinema 3.0.0-beta.2
kerem closed this issue 2026-02-25 20:33:19 +03:00
Author
Owner

@ku1ik commented on GitHub (Feb 8, 2024):

Hmm, probably a deadlock.

What happens when you record with -c bash and launch zsh from bash manually?

<!-- gh-comment-id:1934337467 --> @ku1ik commented on GitHub (Feb 8, 2024): Hmm, probably a deadlock. What happens when you record with `-c bash` and launch `zsh` from bash manually?
Author
Owner

@Pytness commented on GitHub (Feb 8, 2024):

It hangs after exiting bash.

Here is a recording i made with a great tool i found:
asciicast

<!-- gh-comment-id:1934570926 --> @Pytness commented on GitHub (Feb 8, 2024): It hangs after exiting bash. Here is a recording i made with a great tool i found: [![asciicast](https://asciinema.org/a/GlpFdYWUjnXS9buNTCxbIoQQm.svg)](https://asciinema.org/a/GlpFdYWUjnXS9buNTCxbIoQQm)
Author
Owner

@moritzdietz commented on GitHub (Feb 8, 2024):

Just tried to reproduce it – I have zsh, p10k and instant prompt enabled on my Linux Mint x86_64 PC and I wasn't able to. It worked just fine.

Out of curiosity, are you sure you have only one installation of asciinema on your machine? Because the version you specified yells at you for saying where you want to store the recording. Can it be that you have both the rust + python version available on your path and Bash and ZSH get it mixed up?

<!-- gh-comment-id:1934606055 --> @moritzdietz commented on GitHub (Feb 8, 2024): Just tried to reproduce it – I have zsh, p10k and instant prompt enabled on my Linux Mint x86_64 PC and I wasn't able to. It worked just fine. Out of curiosity, are you sure you have only one installation of asciinema on your machine? Because the version you specified yells at you for saying where you want to store the recording. Can it be that you have both the rust + python version available on your path and Bash and ZSH get it mixed up?
Author
Owner

@Pytness commented on GitHub (Feb 9, 2024):

I dont think so. Its a fresh install through cargo install --git ... and whereis outputs the expected .cargo/bin.
By yelling you mean ::: Recording session started, writing to test.cast?

To be clear, I dont see the problem when I comment out the lines sourcing the instant prompt script. Could be something related? I will try using a newer version, maybe it is just outdated.

<!-- gh-comment-id:1935557129 --> @Pytness commented on GitHub (Feb 9, 2024): I dont think so. Its a fresh install through `cargo install --git ...` and `whereis` outputs the expected `.cargo/bin`. By yelling you mean `::: Recording session started, writing to test.cast`? To be clear, I dont see the problem when I comment out the lines sourcing the instant prompt script. Could be something related? I will try using a newer version, maybe it is just outdated.
Author
Owner

@ku1ik commented on GitHub (Feb 9, 2024):

You can try latest develop, yeah.

Btw, what terminal application do you use?

<!-- gh-comment-id:1935560320 --> @ku1ik commented on GitHub (Feb 9, 2024): You can try latest develop, yeah. Btw, what terminal application do you use?
Author
Owner

@Pytness commented on GitHub (Feb 9, 2024):

I am seeing the error on a WSL2 Ubuntu through Wezterm and on an Arch install through ssh in Wezterm

<!-- gh-comment-id:1935576837 --> @Pytness commented on GitHub (Feb 9, 2024): I am seeing the error on a WSL2 Ubuntu through Wezterm and on an Arch install through ssh in Wezterm
Author
Owner

@ku1ik commented on GitHub (Feb 9, 2024):

I tried it now on Arch, using Wezterm, with zsh, p10k, instant prompt (selected verbose mode in the setup wizard), but can't reproduce it either.

<!-- gh-comment-id:1935596313 --> @ku1ik commented on GitHub (Feb 9, 2024): I tried it now on Arch, using Wezterm, with zsh, p10k, instant prompt (selected verbose mode in the setup wizard), but can't reproduce it either.
Author
Owner

@ku1ik commented on GitHub (Feb 9, 2024):

When you ssh to the Arch install, this is from Wezterm running on Windows maybe?

<!-- gh-comment-id:1935597764 --> @ku1ik commented on GitHub (Feb 9, 2024): When you ssh to the Arch install, this is from Wezterm running on Windows maybe?
Author
Owner

@Pytness commented on GitHub (Feb 9, 2024):

I installed p10k again (deleting instant prompt script) and Im getting same results.

When you ssh to the Arch install, this is from Wezterm running on Windows maybe?

Yes it is, but Im getting the same problem when connecting through other apps (I tried with an Android app, JuiceSSH)

<!-- gh-comment-id:1935604793 --> @Pytness commented on GitHub (Feb 9, 2024): I installed p10k again (deleting instant prompt script) and Im getting same results. > When you ssh to the Arch install, this is from Wezterm running on Windows maybe? Yes it is, but Im getting the same problem when connecting through other apps (I tried with an Android app, JuiceSSH)
Author
Owner

@moritzdietz commented on GitHub (Feb 9, 2024):

Maybe this is something in your dotfiles / ZSH setup. Might be worthwhile to go as vanilla as possible and re-add your config things and see where it breaks?

Reason is: I know that when instant prompt launches and there is some kind of delay for it to launch caused by other things in the dotfiles, it will print out things. Maybe this is the case here?

<!-- gh-comment-id:1935610782 --> @moritzdietz commented on GitHub (Feb 9, 2024): Maybe this is something in your dotfiles / ZSH setup. Might be worthwhile to go as vanilla as possible and re-add your config things and see where it breaks? Reason is: I know that when instant prompt launches and there is some kind of delay for it to launch caused by other things in the dotfiles, it will print out things. Maybe this is the case here?
Author
Owner

@ku1ik commented on GitHub (Feb 9, 2024):

Ok, so given it's the same on JuiceSSH, we can rule out Wezterm.

However I'm confused about instant prompt. You first wrote:

To be clear, I dont see the problem when I comment out the lines sourcing the instant prompt script.

And then:

I installed p10k again (deleting instant prompt script) and Im getting same results.

So it does or does not work without instant prompt?

<!-- gh-comment-id:1935624356 --> @ku1ik commented on GitHub (Feb 9, 2024): Ok, so given it's the same on JuiceSSH, we can rule out Wezterm. However I'm confused about instant prompt. You first wrote: > To be clear, I dont see the problem when I comment out the lines sourcing the instant prompt script. And then: > I installed p10k again (deleting instant prompt script) and Im getting same results. So it does or does not work _without_ instant prompt?
Author
Owner

@Pytness commented on GitHub (Feb 9, 2024):

It does work without instant prompt.

I removed the instant prompt script before reinstalling p10k (and configuring) to ensure the last version is installed. Sorry for the confusion.

I will try and bisect where else could it break.

<!-- gh-comment-id:1935633502 --> @Pytness commented on GitHub (Feb 9, 2024): It does work without instant prompt. I removed the instant prompt script before reinstalling p10k (and configuring) to ensure the last version is installed. Sorry for the confusion. I will try and bisect where else could it break.
Author
Owner

@ku1ik commented on GitHub (Feb 9, 2024):

From the demo you recorded it seems to me that the zsh process actually doesn't fully exit. asciinema finishes when the shell process exits and the allocated PTY for the shell gets closed. So, for some reasone the slave side of the PTY doesn't get closed. (this is probably not useful to you, writing this more as a note for myself :))

<!-- gh-comment-id:1935645926 --> @ku1ik commented on GitHub (Feb 9, 2024): From the demo you recorded it seems to me that the zsh process actually doesn't fully exit. asciinema finishes when the shell process exits and the allocated PTY for the shell gets closed. So, for some reasone the slave side of the PTY doesn't get closed. (this is probably not useful to you, writing this more as a note for myself :))
Author
Owner

@Pytness commented on GitHub (Feb 9, 2024):

Doing kill -9 $$ outputs Killed but still the same issue.

<!-- gh-comment-id:1935711102 --> @Pytness commented on GitHub (Feb 9, 2024): Doing `kill -9 $$` outputs Killed but still the same issue.
Author
Owner

@ku1ik commented on GitHub (Feb 9, 2024):

Are you able to install asciinema 2.4.0 and test with it?

<!-- gh-comment-id:1935718968 --> @ku1ik commented on GitHub (Feb 9, 2024): Are you able to install asciinema 2.4.0 and test with it?
Author
Owner

@Pytness commented on GitHub (Feb 9, 2024):

Yes, same result. (I uninstalled the rust version)

<!-- gh-comment-id:1935728280 --> @Pytness commented on GitHub (Feb 9, 2024): Yes, same result. (I uninstalled the rust version)
Author
Owner

@Pytness commented on GitHub (Feb 9, 2024):

I am playing with the source code and It gets stuck at pty::handle_child on execvp.
It seems to me that there is not much to be done?

<!-- gh-comment-id:1935732679 --> @Pytness commented on GitHub (Feb 9, 2024): I am playing with the source code and It gets stuck at pty::handle_child on execvp. It seems to me that there is not much to be done?
Author
Owner

@ku1ik commented on GitHub (Feb 9, 2024):

Right, so this confirms that zsh process doesn't exit, for some reason.

Can you try recording with the script command instead of asciinema? Or with ttyrec?

<!-- gh-comment-id:1936005275 --> @ku1ik commented on GitHub (Feb 9, 2024): Right, so this confirms that zsh process doesn't exit, for some reason. Can you try recording with the `script` command instead of asciinema? Or with `ttyrec`?
Author
Owner

@Pytness commented on GitHub (Feb 12, 2024):

Using script zsh exits.

<!-- gh-comment-id:1938280142 --> @Pytness commented on GitHub (Feb 12, 2024): Using `script` zsh exits.
Author
Owner

@Pytness commented on GitHub (Feb 12, 2024):

Comparing with the script command source code, I found out it calls some function ul_pty_signals_setup.
In that function it sets some signals:

sigaddset(&ourset, SIGCHLD);
sigaddset(&ourset, SIGWINCH);
sigaddset(&ourset, SIGALRM);
sigaddset(&ourset, SIGTERM);
sigaddset(&ourset, SIGINT);
sigaddset(&ourset, SIGQUIT);

I noticed that in asciinema, the sigalrm and sigchld are not being handled.

Handling this signals allows zsh to exit nicely.
I will open a PR.

<!-- gh-comment-id:1938359783 --> @Pytness commented on GitHub (Feb 12, 2024): Comparing with the `script` command source code, I found out it calls some function `ul_pty_signals_setup`. In that function it sets some signals: ``` sigaddset(&ourset, SIGCHLD); sigaddset(&ourset, SIGWINCH); sigaddset(&ourset, SIGALRM); sigaddset(&ourset, SIGTERM); sigaddset(&ourset, SIGINT); sigaddset(&ourset, SIGQUIT); ``` I noticed that in `asciinema`, the `sigalrm` and `sigchld` are not being handled. Handling this signals allows zsh to exit nicely. I will open a PR.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asciinema#317
No description provided.