From b4cbcbdbbb8be942b887d1e069a97ae5506563db Mon Sep 17 00:00:00 2001 From: garywill Date: Sat, 16 Aug 2025 10:09:08 +0800 Subject: [PATCH] is_same_netns: handle if not same pidns --- lnxrouter | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lnxrouter b/lnxrouter index 828622f..b9ae55f 100755 --- a/lnxrouter +++ b/lnxrouter @@ -932,8 +932,12 @@ get_pid_by_dbus_name() { } is_same_netns() { local pid2="$1" + local my_netns his_netns [[ ! -f /proc/$$/ns/net ]] && return 0 # no netns feature. treat as same - [[ "$(readlink /proc/$$/ns/net)" == "$(readlink /proc/$pid2/ns/net)" ]] && return 0 + my_netns="$(readlink /proc/$$/ns/net)" + his_netns="$(readlink /proc/$pid2/ns/net)" + [[ ! -n "$his_netns" ]] && return 1 # can't find his pid or netns (maybe different pidns), treat as not same + [[ "$my_netns" == "$his_netns" ]] && return 0 return 1 } #-----------------