From f061c0285a2dad01c61a8766131002e1831566cc Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Sun, 14 Sep 2025 15:06:09 +0300 Subject: [PATCH 1/2] fix: Fix test execution hanging issue - Replace `os.execute()` with `os.system()` - Avoid hanging due to unclosed file descriptors - Update error message to include command exit code --- test_basic.vsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test_basic.vsh b/test_basic.vsh index ece1fbec..8811c5f0 100755 --- a/test_basic.vsh +++ b/test_basic.vsh @@ -121,11 +121,11 @@ fn dotest(path string, base_dir string, mut cache TestCache) ! { cmd := 'v -stats -enable-globals -n -w -gc none test ${norm_path}' println(cmd) - result := os.execute(cmd) - eprintln(result) - if result.exit_code != 0 { - eprintln('Test failed: ${path}') - eprintln(result.output) + + // Use system() instead of execute() to avoid hanging on unclosed file descriptors + exit_code := os.system(cmd) + if exit_code != 0 { + eprintln('Test failed: ${path} (exit code: ${exit_code})') exit(1) } From 42cf8949f70a19fc0dbb499fc9a80310a165f2fe Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Sun, 14 Sep 2025 15:26:55 +0300 Subject: [PATCH 2/2] perf: Limit command output in SSH agent functions - Limit `pgrep` output in agent cleanup - Limit `find` output for socket validation - Limit `ssh-add` output for key initialization --- lib/osal/sshagent/sshagent.v | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/osal/sshagent/sshagent.v b/lib/osal/sshagent/sshagent.v index de271835..2893c703 100644 --- a/lib/osal/sshagent/sshagent.v +++ b/lib/osal/sshagent/sshagent.v @@ -62,8 +62,8 @@ pub fn (mut agent SSHAgent) is_agent_responsive() bool { pub fn (mut agent SSHAgent) cleanup_orphaned_agents() ! { user := os.getenv('USER') - // Find ssh-agent processes for current user - res := os.execute('pgrep -u ${user} ssh-agent') + // Find ssh-agent processes for current user (limit to prevent memory issues) + res := os.execute('pgrep -u ${user} ssh-agent | head -20') if res.exit_code == 0 && res.output.len > 0 { pids := res.output.trim_space().split('\n') @@ -82,8 +82,8 @@ pub fn (mut agent SSHAgent) cleanup_orphaned_agents() ! { // check if specific agent PID is valid and responsive fn (mut agent SSHAgent) is_agent_pid_valid(pid int) bool { - // Try to find socket for this PID - res := os.execute('find /tmp -name "agent.*" -user ${os.getenv('USER')} 2>/dev/null | head -10') + // Try to find socket for this PID (limit output to prevent memory issues) + res := os.execute('find /tmp -maxdepth 1 -name "agent.*" -user ${os.getenv('USER')} 2>/dev/null | head -5') if res.exit_code != 0 { return false } @@ -154,9 +154,9 @@ pub fn (mut agent SSHAgent) diagnostics() map[string]string { // get all keys from sshagent and from the local .ssh dir pub fn (mut agent SSHAgent) init() ! { - // first get keys out of ssh-add + // first get keys out of ssh-add (limit output to prevent memory issues) agent.keys = []SSHKey{} - res := os.execute('ssh-add -L') + res := os.execute('ssh-add -L | head -100') if res.exit_code == 0 { for line in res.output.split('\n') { if line.trim(' ') == '' {