fix(display): use execSync shell pipe instead of fs.writeFileSync to avoid EINVAL
Made-with: Cursor
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user