fix(display): use execSync shell pipe instead of fs.writeFileSync to avoid EINVAL

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-18 21:11:22 +08:00
parent 9da4cd0aa1
commit a737101c2e

View File

@@ -1,6 +1,7 @@
'use strict';
const fs = require('fs');
const { execSync } = require('child_process');
const log = require('./logger');
/**
@@ -110,9 +111,10 @@ class Display {
_write(val) {
try {
fs.writeFileSync(DISPLAY_PATH, val);
// 用 shell 管道写入,与 echo "..." | tee ... 行为完全一致
execSync(`echo "${val}" | tee ${DISPLAY_PATH} > /dev/null`, { timeout: 3000 });
} catch (e) {
log.warn('display', `写入失败 (${DISPLAY_PATH}): ${e.message}`);
log.warn('display', `写入失败: ${e.message}`);
}
}
}