On Unix, the return value is the exit status of the process encoded in the format specified for wait(). Note that POSIX does not specify the meaning of the return value of the C system() function, so the return value of the Python function is system-dependent.
Wait for completion of a child process, and return a tuple containing its pid and exit status indication: a 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero); the high bit of the low byte is set if a core file was produced.
根据the docs:
和the ^{} docs say :
因此0、256和512对应于}常用来表示参数解析失败)。在本例中,您传递了
ping
正常退出(不被信号杀死),退出状态为0 == 0 << 8
(0
传统上表示“成功”)、256 == 1 << 8
(1
通常表示“正常”失败)和512 == 2 << 8
(不一致,但{-s
,但没有提供开关所需的强制值(packetsize
),因此退出状态2
是有意义的。在相关问题 更多 >
编程相关推荐