linux - POSIX 将用户输入可接受的字符数限制为 4096,如何增加?

标签 linux terminal posix pipe

query

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

  1. 参数长度的 POSIX 最小允许上限(所有系统):4096 使用命令检查:xargs --show-limits
  2. 管道缓冲区大小:4096 使用命令检查:ulimit -aulimit -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/

相关文章:

linux - 如何将列数据传输到行(使用awk)?

linux - Ubuntu 中 lampp 的文件权限

bash - 为什么 bash 无法在/usr/local/bin 中创建符号链接(symbolic link)?

c - pty 终端数据包模式 TIOCPKT

c - 为什么 open/send/sendto/sendmsg 函数中的标志参数是有符号整数而不是无符号整数?

python - numpy undefined symbol : PyFPE_jbuf

java - 使用 Java 获取 awk 返回值

c - 带轮询的非阻塞套接字

写入数据报套接字是否可以引发 SIGPIPE?

Linux 历史详细信息