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

piping to a screen pager (e.g. less(1) or more(1)) blocks program #2

Closed
bxparks opened this issue Aug 13, 2019 · 3 comments
Closed

Comments

@bxparks
Copy link
Owner

bxparks commented Aug 13, 2019

As noted in the README.md, if the executable (e.g. SampleTest.out) is piped to a screen pager like less(1) or more(1), sometimes (not all the time) the executable hangs and displays nothing on the pager program. The program seems to be blocking on the standard input. The problem is probably caused by an interaction between how the screen pager manipulates the stdin and how I place the stdin into "raw" mode in Arduino.cpp. I would love to fix this, but I don't know enough about Unix tty device configuration to figure this out.

In the meantime, the workaround is to explicitly redirect the stdin using /dev/null, like this:

$ ./SampleTest.out | less # hangs
$ ./SampleTest.out < /dev/null | less # works
@mmrazik
Copy link

mmrazik commented Mar 20, 2021

@bxparks please see my pull request

bxparks added a commit that referenced this issue Mar 21, 2021
Explicitly set O_NONBLOCK to stdin while running tests #2
@bxparks
Copy link
Owner Author

bxparks commented Mar 22, 2021

@mmrazik: Let's transfer the discussion from #24 to here.

The number of lines needed to trigger the error seems to be variable. Changes across machine and OS, sometimes different on the same machine. I checked in a version of PipeFail that prints out 2000 lines, and that seems to trigger this problem on all machines that I tested today:

  • Ubuntu MATE 20.04
  • Linux Mint 20 (20.04 based)
  • Mac OS 10.13.3 (Mojave)
  • FreeBSD 12.2

@bxparks
Copy link
Owner Author

bxparks commented Sep 30, 2021

I believe I have finally fixed this with bf6248f.

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