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

Interaction with fork. #24

Open
pveber opened this issue Nov 22, 2021 · 2 comments
Open

Interaction with fork. #24

pveber opened this issue Nov 22, 2021 · 2 comments

Comments

@pveber
Copy link

pveber commented Nov 22, 2021

I have a program that forks repeatedly inside a Progress.with_reporter call, and it seems each time it happens, there's a return carriage that gets printed to the screen. Next time the bar is rendered, it is added below the former render, instead of replacing it, like in:

Processing alignments  0/10 [------------------------------------------------------------------------------------------------------------------] 00:02
Processing alignments  1/10 [###########-------------------------------------------------------------------------------------------------------] 00:33
Processing alignments  2/10 [######################--------------------------------------------------------------------------------------------] 00:34

I'm not absolutely sure this is due to forking, but I highly suspect it. I see no reason for this, however. Maybe there's something I could call in the child process to disable any further interaction with the terminal?

@edwintorok
Copy link

edwintorok commented Mar 20, 2024

I think this is due to the default hide_cursor which registers an at_exit handler that prints a newline and re-enables the cursor.
Try this, it fixed the problem for me:

let config = Progress.Config.v ~hide_cursor:false () in
Progress.with_reporters ~config 

@edwintorok
Copy link

This could probably be fixed by checking the pid of the process in at_exit, and only running the at_exit handler if it matches the PID of the process it got registered in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants