traffic: evoke OS error codes by name, not number
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 22 Nov 2018 00:00:04 +0000 (13:00 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 8 Jan 2019 22:55:33 +0000 (23:55 +0100)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/emulate/traffic.py

index 6dfc9c6..553ce5c 100644 (file)
@@ -25,6 +25,7 @@ import json
 import math
 import sys
 import signal
+from errno import ECHILD, ESRCH
 
 from collections import OrderedDict, Counter, defaultdict, namedtuple
 from samba.emulate import traffic_packets
@@ -1617,7 +1618,7 @@ def replay(conversation_seq,
                 try:
                     os.kill(pid, s)
                 except OSError as e:
-                    if e.errno != 3:  # don't fail if it has already died
+                    if e.errno != ESRCH:  # don't fail if it has already died
                         raise
             time.sleep(0.5)
             end = time.time() + 1
@@ -1625,7 +1626,7 @@ def replay(conversation_seq,
                 try:
                     pid, status = os.waitpid(-1, os.WNOHANG)
                 except OSError as e:
-                    if e.errno != 10:
+                    if e.errno != ECHILD:
                         raise
                 if pid != 0:
                     c = children.pop(pid, None)