TODO:Golang Linux进程退出说明

TODO:Golang Linux进程退出说明

Golang使用os.Exit(code)进程退出导致当前程序退出并返回给定的状态代码。传统上,code代码为零表示成功退出,非零错误退出。

syscall.Exit可以调用不同平台的操作系统的退出。

code值为0-255,当code为非0时,os.Exit(code)会返回,对应值当状态码

exit status 128

当code为0,则正常退出。code值可自定义对应当意义进行相应业务场景使用。code的值在自然数是按从0至255的倍数进行循环,例如自然数为256,在进程退出的时候返回的是0;256-511==》code值为0-255,负数也是一样,-256到-1==》0-255。

退出码是使用情景,在linux下使用得淋漓尽致

0 命令成功完成

1 通常的未知错误

2 误用shell命令

126 命令无法执行

127 没有找到命令

128 无效的退出参数

128 +x使用Linux信号x的致命错误。

130 使用Ctrl-C终止的命令

255 规范外的退出状态

echo $?是输出上一个命令的退出码,从图中我们看到了0,126,127都是我们意料的情况。这是Linux下的退出码的使用情况,我们自己的软件也可以自我定义。


wxgzh:ludong86

qrcode_for_gh_6bb1f39ae99c_258-1

填充下面这个程序中所有出现// TODO: fill the code这个任务的地方#include <iostream> #include <cstring> #include "ourstring.h" #include "strlib.h" using namespace std; OurString::OurString(){ // TODO: fill the code } OurString::OurString(const char *str){ // TODO: fill the code } OurString::OurString(const OurString &dstr){ // TODO: fill the code } OurString::~OurString(){ // TODO: fill the code } string OurString::toString() const{ // TODO: fill the code } OurString OurString::subStr(unsigned int start, unsigned int n) const{ // TODO: fill the code } bool OurString::operator > (const OurString &dstr) const{ // TODO: fill the code } bool OurString::operator < (const OurString &dstr) const{ // TODO: fill the code } bool OurString::operator == (const OurString &dstr) const{ // TODO: fill the code } unsigned int OurString::length () const{ // TODO: fill the code } const OurString& OurString::operator = (const OurString &dstr){ // TODO: fill the code } const OurString& OurString::operator = (const char *str){ // TODO: fill the code } char& OurString::operator[](int index){ // TODO: fill the code } const OurString OurString::operator + (const OurString &dstr) const{ // TODO: fill the code } const OurString OurString::operator + (const char *str) const{ // TODO: fill the code } const OurString& OurString::operator += (const OurString &dstr){ // TODO: fill the code } const OurString& OurString::operator += (const char *str){ // TODO: fill the code } ostream & operator<<(ostream &os, const OurString &dstr){ // TODO: fill the code } istream & operator>>(istream &is, OurString &dstr){ // TODO: fill the code }
最新发布
05-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值