-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Labels
bugSomething isn't workingSomething isn't working
Description
fgets() returns prematurely in non-canonical input mode
Description:
When fgets() is used with STDIN_FILENO and the process has ICANON disabled in its termios configuration, the function may return immediately without blocking for a full line, even if no input is available. This violates the expected behavior of fgets(), which should block until a full line is available (ending with \n) or EOF is reached.
Steps to Reproduce:
- Disable
ICANONandECHOin a user process. - Call
fgets(buf, size, STDIN_FILENO). - Observe that the call returns immediately with a possibly empty or partial string.
Expected Behavior:
fgets() should block until a full line is available, even in non-canonical mode, or otherwise simulate canonical behavior.
Suggested Fix:
Either:
- Force
fgets()to block and accumulate until\nis read, regardless of terminal mode, or - Document that
fgets()must be used in canonical mode only.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working