attempt fix linux waitExit error

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Jan 31, 2026 at 15:30 UTC a3ff9294dfaebd51f81f6a0f1ed79104ac9630e8
1 file changed +14 -15
agents/modules_meshcore/computer-identifiers.js
+14 -15
@@ -18,7 +18,8 @@ function trimIdentifiers(val)
18 {
19 for(var v in val)
20 {
21 - if (!val[v] || val[v] == 'None' || val[v] == '' || val[v].trim() == '') { delete val[v]; }
21 + if(typeof val[v] === 'string') val[v] = val[v].trim();
22 + if (!val[v] || val[v] == 'None' || val[v] == '') { delete val[v]; }
23 }
24 }
25 function trimResults(val)
@@ -68,6 +69,7 @@ function linux_identifiers()
69 var identifiers = {};
70 var ret = {};
71 var values = {};
72 + var child = null;
73
74 if (!require('fs').existsSync('/sys/class/dmi/id')) {
75 if (require('fs').existsSync('/sys/firmware/devicetree/base/model')) {
@@ -76,7 +78,7 @@ function linux_identifiers()
78 identifiers['board_name'] = require('fs').readFileSync('/sys/firmware/devicetree/base/model').toString().trim();
79 identifiers['board_serial'] = require('fs').readFileSync('/sys/firmware/devicetree/base/serial-number').toString().trim();
80 const memorySlots = [];
79 - var child = require('child_process').execFile('/bin/sh', ['sh']);
81 + child = require('child_process').execFile('/bin/sh', ['sh']);
82 child.stdout.str = ''; child.stdout.on('data', dataHandler);
83 child.stdin.write('vcgencmd get_mem arm && vcgencmd get_mem gpu\nexit\n');
84 child.waitExit();
@@ -122,20 +124,20 @@ function linux_identifiers()
124 identifiers['bios_mode'] = (require('fs').statSync('/sys/firmware/efi').isDirectory() ? 'UEFI': 'Legacy');
125 } catch (ex) { identifiers['bios_mode'] = 'Legacy'; }
126
125 - var child = require('child_process').execFile('/bin/sh', ['sh']);
127 + child = require('child_process').execFile('/bin/sh', ['sh']);
128 child.stdout.str = ''; child.stdout.on('data', dataHandler);
129 child.stdin.write('cat /proc/cpuinfo | grep -i "model name" | ' + "tr '\\n' ':' | awk -F: '{ print $2 }'\nexit\n");
130 child.waitExit();
129 - identifiers['cpu_name'] = child.stdout.str.trim();
130 - if (identifiers['cpu_name'] == "") { // CPU BLANK, check lscpu instead
131 - child = require('child_process').execFile('/bin/sh', ['sh']);
132 - child.stdout.str = ''; child.stdout.on('data', dataHandler);
133 - child.stdin.write('lscpu | grep -i "model name" | ' + "tr '\\n' ':' | awk -F: '{ print $2 }'\nexit\n");
134 - child.waitExit();
131 + try {
132 identifiers['cpu_name'] = child.stdout.str.trim();
136 - }
137 - child = null;
138 -
133 + if (identifiers['cpu_name'] == "") { // CPU BLANK, check lscpu instead
134 + child = require('child_process').execFile('/bin/sh', ['sh']);
135 + child.stdout.str = ''; child.stdout.on('data', dataHandler);
136 + child.stdin.write('lscpu | grep -i "model name" | ' + "tr '\\n' ':' | awk -F: '{ print $2 }'\nexit\n");
137 + child.waitExit();
138 + try { identifiers['cpu_name'] = child.stdout.str.trim(); } catch (xx) { }
139 + }
140 + } catch (xx) { }
141
142 // Fetch GPU info
143 child = require('child_process').execFile('/bin/sh', ['sh']);
@@ -143,7 +145,6 @@ function linux_identifiers()
145 child.stdin.write("lspci | grep ' VGA ' | tr '\\n' '`' | awk '{ a=split($0,lines" + ',"`"); printf "["; for(i=1;i<a;++i) { split(lines[i],gpu,"r: "); printf "%s\\"%s\\"", (i==1?"":","),gpu[2]; } printf "]"; }\'\nexit\n');
146 child.waitExit();
147 try { identifiers['gpu_name'] = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
146 - child = null;
148
149 // Fetch Storage Info
150 child = require('child_process').execFile('/bin/sh', ['sh']);
@@ -151,7 +152,6 @@ function linux_identifiers()
152 child.stdin.write("lshw -class disk -disable network | tr '\\n' '`' | awk '" + '{ len=split($0,lines,"*"); printf "["; for(i=2;i<=len;++i) { model=""; caption=""; size=""; clen=split(lines[i],item,"`"); for(j=2;j<clen;++j) { split(item[j],tokens,":"); split(tokens[1],key," "); if(key[1]=="description") { caption=substr(tokens[2],2); } if(key[1]=="product") { model=substr(tokens[2],2); } if(key[1]=="size") { size=substr(tokens[2],2); } } if(model=="") { model=caption; } if(caption!="" || model!="") { printf "%s{\\"Caption\\":\\"%s\\",\\"Model\\":\\"%s\\",\\"Size\\":\\"%s\\"}",(i==2?"":","),caption,model,size; } } printf "]"; }\'\nexit\n');
153 child.waitExit();
154 try { identifiers['storage_devices'] = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
154 - child = null;
155
156 // Fetch storage volumes using df
157 child = require('child_process').execFile('/bin/sh', ['sh']);
@@ -159,7 +159,6 @@ function linux_identifiers()
159 child.stdin.write('df -T -x tmpfs -x devtmpfs -x efivarfs | awk \'NR==1 || $1 ~ ".+"{print $3, $4, $5, $7, $2}\' | awk \'NR>1 {printf "{\\"size\\":\\"%s\\",\\"used\\":\\"%s\\",\\"available\\":\\"%s\\",\\"mount_point\\":\\"%s\\",\\"type\\":\\"%s\\"},", $1, $2, $3, $4, $5}\' | sed \'$ s/,$//\' | awk \'BEGIN {printf "["} {printf "%s", $0} END {printf "]"}\'\nexit\n');
160 child.waitExit();
161 try { ret.volumes = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
162 - child = null;
162
163 values.identifiers = identifiers;
164 values.linux = ret;