我创建了一个接受用户输入(字符串)的 Java 程序。问题是终端不允许我提供大于 4096 个字符的输入。造成这种情况的问题可能是:
- 参数长度的 POSIX 最小允许上限(所有系统):4096
使用命令检查:
xargs --show-limits
- 管道缓冲区大小:4096
使用命令检查:
ulimit -a
或ulimit -p
谁能建议我如何增加这些值?或者我怎样才能增加允许作为用户输入的字符数。
我想接受大约 1 MB 的数据作为参数。
最佳答案
正如 Mali 所说:stty -icanon
在启动程序之前在终端中...解决了问题..
POSIX systems support two basic modes of input: canonical and noncanonical (or raw mode).
In canonical input processing mode, terminal input is processed in lines terminated by newline ('\n'), EOF, or EOL characters. The operating system provides input editing facilities: the ERASE and KILL characters are interpreted specially to perform editing operations within the current line of text.
In noncanonical input processing mode (raw mode), characters are not grouped into lines, and ERASE and KILL processing is not performed. The granularity with which bytes are read in raw mode is controlled by the MIN and TIME settings (see man termios the VMIN and VTIME value. VMIN specifies the minimum number of bytes before a read returns. VTIME specifies the number of tenths of a second to wait for data to arrive.
More bascally, in canonical mode, input are accumulated in a buffer (4096) until a \n occured. In raw mode, input is flushed when VMIN or VTIME occured
谢谢马里..
关于linux - POSIX 将用户输入可接受的字符数限制为 4096,如何增加?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18226274/