Hi All, I`ve noted that ngets() from libstand starts consuming CPU like mad when EOF appears on stdin. I see this issue with bhyveload when forwarding "user input" over pipe. Here is the simpliest program to reproduce: cat > ./bget.c #include #include #include #include int main() { char str[512]; for (;;) { ngets(str, sizeof(str)); if (str[0] == '\n') // <--- The program shall exit on \nEOF here, but it // spins inside ngets() and does not reach this point break; } return 0; } $ echo "balbalbalabl" | ./bget & $ There is no problem in libstand when it is used in the real boot loader, but inside bhyveload it has a bug described above. There is a github pull request with suggested patch https://github.com/freebsd/freebsd/pull/23
Can you show an example of what you're doing with bhyve? When I try to pipe input in the vm just exits on the EOF.
A commit references this bug: Author: kevans Date: Thu Aug 9 02:55:48 UTC 2018 New revision: 337523 URL: https://svnweb.freebsd.org/changeset/base/337523 Log: libsa: exit on EOF in ngets It was possible in some rare circumstances for ngets to behave terribly with bhyveload and some form of redirecting user input over a pipe. PR: 198706 Submitted by: Ivan Krivonos <int0dster@gmail.com> MFC after: 1 week Changes: head/stand/libsa/gets.c
A commit references this bug: Author: kevans Date: Mon Aug 20 00:49:06 UTC 2018 New revision: 338077 URL: https://svnweb.freebsd.org/changeset/base/338077 Log: MFC r337523: libsa: exit on EOF in ngets It was possible in some rare circumstances for ngets to behave terribly with bhyveload and some form of redirecting user input over a pipe. PR: 198706 Changes: _U stable/11/ stable/11/stand/libsa/gets.c
There is a commit referencing this PR, but it's still not closed and has been inactive for some time. Closing the PR as fixed but feel free to re-open it if the issue hasn't been completely resolved. Thanks