소스 검색

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

불러오는 중...
취소
저장