# process.pipe_limit

## 功能

设置当前 Process 对象 stdout/stderr 管道的未读缓冲上限。适合长时间运行、持续输出进度的子进程，调用方可以按业务吞吐提高上限，例如桌面批处理任务设置为 16MB。

## 语法

```bt
process(program).pipe_limit(bytes)
```

## 参数

| 参数 | 类型 | 必填 | 默认值 | 有效范围 | 说明 |
| ------ | ------ | ------ | ------ | ------ | ------ |
| bytes | Int | 是 | 无 | 大于 0，且必须大于等于 BT_PROCESS_PIPE_READ_CHUNK | 单个 stdout 或 stderr 管道允许暂存的未读字节数。 |

## 返回值

| 类型 | 说明 |
| ------ | ------ |
| Process | 返回新的进程构建器。 |

## 示例

```bt
cmd = process('docx_to_img.exe')
    .pipe_limit(16 * 1024 * 1024)
    .child()

result = cmd.stdout().limit

// 输出：16777216
print result
```

## 注意事项

- pipe_limit(bytes) 只影响当前 Process 对象，不修改全局环境变量。
- 未调用 pipe_limit(bytes) 时，默认读取 BT_PROCESS_PIPE_LIMIT；未配置环境变量时默认 1048576 字节。
- BT_PROCESS_PIPE_LIMIT 和 pipe_limit(bytes) 限制的是“已从系统管道读出但尚未被 stdout_read/stderr_read 取走”的未读缓冲，不是进程生命周期内的历史累计输出。
- 如果未读缓冲超过上限，stdout_read/stderr_read 会返回运行时错误；后台读取线程仍会继续排空系统管道，避免子进程因为管道写满而卡住。
