瀏覽代碼

ignore EPIPE happens on RHEL

Matthew Wang 12 年之前
父節點
當前提交
29c9e1f58c
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7
    2
      src/cdiff.py

+ 7
- 2
src/cdiff.py 查看文件

16
 
16
 
17
 import os
17
 import os
18
 import re
18
 import re
19
+import errno
19
 import difflib
20
 import difflib
20
 
21
 
21
 
22
 
492
         # args stolen fron git source: github.com/git/git/blob/master/pager.c
493
         # args stolen fron git source: github.com/git/git/blob/master/pager.c
493
         pager = subprocess.Popen(['less', '-FRSXK'],
494
         pager = subprocess.Popen(['less', '-FRSXK'],
494
                 stdin=subprocess.PIPE, stdout=sys.stdout)
495
                 stdin=subprocess.PIPE, stdout=sys.stdout)
495
-        for line in color_diff:
496
-            pager.stdin.write(line)
496
+        try:
497
+            for line in color_diff:
498
+                pager.stdin.write(line)
499
+        except IOError as e:
500
+            if e.errno == errno.EPIPE:
501
+                pass
497
 
502
 
498
         pager.stdin.close()
503
         pager.stdin.close()
499
         pager.wait()
504
         pager.wait()