0

询问

我创建了一个接受用户输入(字符串)的 java 程序。问题是终端不允许我提供大于 4096 个字符的输入。造成这种情况的问题可能是:

  1. POSIX 参数长度的最小允许上限(所有系统):4096 使用以下命令检查:xargs --show-limits
  2. 管道缓冲区大小:4096 使用命令检查:ulimit -aulimit -p

谁能建议我如何增加这些值?或者如何增加允许作为用户输入的字符数。

我想接受大约 1 mb 的数据作为参数。

4

1 回答 1

2

正如马里所说: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

谢谢马里..

于 2013-08-14T08:31:08.260 回答