Skip to content

Commit 7de1ecd

Browse files
committed
Fix issues with vanishing PIDs when calling "enroot list -f"
Fixes: NVIDIA#126 Signed-off-by: Felix Abecassis <[email protected]>
1 parent 2bd5143 commit 7de1ecd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/runtime.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,11 @@ runtime::list() {
515515
# Look for all the pids associated with any of the rootfs.
516516
for pid in $(lsns -n -r -t mnt -o pid); do
517517
if [ -e "/proc/${pid}/root/${lock_file}" ]; then
518-
name=$(awk '($5 == "/"){print $4; exit}' "/proc/${pid}/mountinfo" 2> /dev/null)
518+
name=$(awk '($5 == "/"){print $4; exit}' "/proc/${pid}/mountinfo" 2> /dev/null || echo "<gone>")
519+
if [ "${name}" = "<gone>" ]; then
520+
continue
521+
fi
522+
519523
if [ -n "${info["${name#${cwd}}"]+x}" ]; then
520524
info["${name#${cwd}}"]+=" ${pid} "
521525
else
@@ -539,7 +543,7 @@ runtime::list() {
539543
printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t", $1, comm, $2, $3, $4, $5, $6
540544
print substr($0, index($0, $7))
541545
close("/proc/"$1"/comm")
542-
}'
546+
}' || printf "%s\n" "${name}"
543547
fi
544548
done
545549
} | column -t -s $'\t'

0 commit comments

Comments
 (0)