浏览代码

Rewrite GDB command to stop on the first error, e.g. if lsof is broken.

The use of call("echo 'string'") instead of print('string') or sys.stdout.write('string') is due to the latter two not reliably reporting back whether they were successful or not: print doesn't return anything (and actually can't be chained like this), and the return value of sys.stdout.write depends on the Python version (None on Python 2, number of bytes written on Python 3).
master
JustAnotherArchivist 6 年前
父节点
当前提交
10715f1d3a
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. +2
    -3
      kill-wpull-connections

+ 2
- 3
kill-wpull-connections 查看文件

@@ -50,9 +50,8 @@ fi

gdb -batch -batch-silent \
-ex "attach ${wpullPid}" \
-ex 'shell echo "FDs before forced shutdown:"; lsof -an -p '${wpullPid}' -i TCP | grep -v 127\.0\.0\.1' \
-ex 'python import subprocess' \
-ex 'python for fd in subprocess.check_output("lsof -an -p '${wpullPid}' -i TCP -F pfn | awk '\''NR%2==0{fd=substr($0,2)}NR%2==1&&NR>1&&!/127\.0\.0\.1/{print fd}'\''", shell = True).decode("ascii").strip().split("\n"): gdb.execute("p shutdown(" + fd + ", 2)")' \
-ex 'shell echo "FDs after forced shutdown:"; lsof -an -p '${wpullPid}' -i TCP | grep -v 127\.0\.0\.1' \
-ex 'python def call(s): return subprocess.call(s, shell = True) == 0' \
-ex 'python call("echo '\''FDs before forced shutdown:'\''") and call("lsof -an -p '${wpullPid}' -i TCP | grep -v 127\.0\.0\.1") and ([gdb.execute("p shutdown(" + fd + ", 2)") for fd in subprocess.check_output("lsof -an -p '${wpullPid}' -i TCP -F pfn | awk '\''NR%2==0{fd=substr($0,2)}NR%2==1&&NR>1&&!/127\.0\.0\.1/{print fd}'\''", shell = True).decode("ascii").strip().split("\n")] or True) and call("echo '\''FDs after forced shutdown:'\''") and call("lsof -an -p '${wpullPid}' -i TCP | grep -v 127\.0\.0\.1")' \
-ex detach \
-ex quit

正在加载...
取消
保存