def decode_wait_status(sts):
 if os.WIFEXITED(sts):
  es = (os.WEXITSTATUS(sts) & 65535)
  msg = ('exit status %s' % es)
  return (es, msg)
 elif os.WIFSIGNALED(sts):
  sig = os.WTERMSIG(sts)
  msg = ('terminated by %s' % signame(sig))
  if hasattr(os, 'WCOREDUMP'):
   iscore = os.WCOREDUMP(sts)
  else:
   iscore = (sts & 128)
  if iscore:
   msg += ' (core dumped)'
  return ((-1), msg)
 else:
  msg = ('unknown termination cause 0x%04x' % sts)
  return ((-1), msg)

def decode_wait_status ( sts ) : if os . WIFEXITED ( sts ) : es = ( os . WEXITSTATUS ( sts ) & 65535 ) msg = ( 'exit status %s' % es ) return ( es , msg ) elif os . WIFSIGNALED ( sts ) : sig = os . WTERMSIG ( sts ) msg = ( 'terminated by %s' % signame ( sig ) ) if hasattr ( os , 'WCOREDUMP' ) : iscore = os . WCOREDUMP ( sts ) else : iscore = ( sts & 128 ) if iscore : msg += ' (core dumped)' return ( ( - 1 ) , msg ) else : msg = ( 'unknown termination cause 0x%04x' % sts ) return ( ( - 1 ) , msg )
decode the status returned by wait() or waitpid() .