Kenny McCormack
unread,Apr 21, 2021, 7:54:56 PM4/21/21You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I got this sorted, and it turns out to have been a bug (typo) in one of my
Expect scripts - that was causing it to not close the ptmx end of the jobs
that it spawns. It was spawning jobs in a loop and not closing them
properly, so you can guess what the result of that would be.
Anyway, here are the two scripts I wrote to debug this problem:
1) Part1 is a script to find all processes (that I own) that have /dev/ptmx
open:
--- Cut Here ---
#!/bin/bash
# Run this with no args
# Note: If you don't have setsort on your system, just remove the
# references to it. setsort will make the pids come out in numerical
# order, but it isn't necessary.
ls -lsa /proc/*/fd 2>/dev/null | gawk -i setsort '
sub(/^\/proc\//,"") { pid=$0+0;next }
/\/dev\/ptmx/ { x[pid] = x[pid] " " $10 }
END { setsort(2);for (i in x) print i,x[i] }
'
--- Cut Here ---
Run this and it will produce a line of output for each process that has
/dev/ptms open, like this:
<pid> <fd1> <fd2> ...
2) Part2 is a script to launch gdb on each process found above and display
the pts associated with each fd:
--- Cut Here ---
#!/usr/bin/expect --
# The args to this program are generated by the previous script.
# First arg is a pid, subsequent args are fds that point to /dev/ptmx.
set timeout -1
log_file typescript
spawn gdb -p [lindex $argv 0]
expect {
ptrace: { sleep 1;send q\r;expect;exit 1 }
"(gdb)"
}
for {set i 1} {$i < $argc} {incr i} {
send "p (char *) ptsname([lindex $argv $i])\r"
expect "(gdb)"
}
send q\r
expect anyway
sleep 1
send y\r
expect
--- Cut Here ---
Once I ran Part2, it was easy to find the Expect script that had too many
instances of /dev/ptms open.
So, problem solved - Expect script bug fixed - and thanks to all for the
help in getting this sorted.
--
Politics is show business for ugly people.
Sports is politics for stupid people.