Bug 198706 - [libstand] ngets shall exit on EOF
Summary: [libstand] ngets shall exit on EOF
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
Keywords: patch
Depends on:
Reported: 2015-03-19 14:14 UTC by Ivan Krivonos
Modified: 2017-03-01 06:09 UTC (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Krivonos 2015-03-19 14:14:44 UTC
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


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
    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

Comment 1 Bryan Drewery freebsd_committer 2016-03-04 23:23:43 UTC
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.