Closed waitspring closed 1 year ago
按照Linux命令的设计规范,如果tcping探测一个套接字失败,应该使用异常退出码退出,而非使用正常退出码0退出。 例如:
0
$ tcping -c 1 128.0.0.1 22 Ping tcp://128.0.0.1:22 - failed: dial tcp 128.0.0.1:22: i/o timeout Ping statistics tcp://128.0.0.1:22 1 probes sent. 0 successful, 1 failed. # 命令执行失败 Approximate trip times: Minimum = 0s, Maximum = 0s, Average = 0s $ echo $? 0 # Linux环境下为正常退出码
在此,给出ping命令的退出码示例:
$ ping -c 1 128.0.0.1 PING 128.0.0.1 (128.0.0.1) 56(84) bytes of data. --- 128.0.0.1 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms # 命令执行失败 $ echo $? 1 # Linux环境下为异常退出码
按照Linux命令的设计规范,如果tcping探测一个套接字失败,应该使用异常退出码退出,而非使用正常退出码
0
退出。 例如:在此,给出ping命令的退出码示例: