当前位置: 首页 > news >正文

discuz网站论坛间帖子转移seo优化销售话术

discuz网站论坛间帖子转移,seo优化销售话术,网站快捷按钮以什么方式做,网站移动页面怎么做的目录 一、写时拷贝 1.创建子进程 2.写时拷贝 二、进程终止 1.函数返回值 2.错误码 3.异常退出 4.exit 5._exit 一、写时拷贝 父子进程,代码共享,不作写入操作时,数据也是共享的,当任意一方试图写入,便通过写时拷…

目录

一、写时拷贝

1.创建子进程

2.写时拷贝

 二、进程终止

1.函数返回值

2.错误码

3.异常退出

4.exit

5._exit


一、写时拷贝

        父子进程,代码共享,不作写入操作时,数据也是共享的,当任意一方试图写入,便通过写时拷贝的方式各自有一份副本。

1.创建子进程

        这是父进程的大致蓝图。

        创建子进程,分配内存块内核数据结构给子进程。

         将父进程的部分数据结构内容拷贝到子进程,即代码内容共享数据内容暂时共享

2.写时拷贝

  • 写实拷贝的大致蓝图

  • 为什么要作写时拷贝?

        子进程不一定会用到父进程的全部数据,故作写时拷贝用来完成特定的数据需求。

  • 页表

        页表并不是只有虚拟地址和物理地址两列,还有其他属性列,如“权限”、“是否存在于内存”。权限列有只读、可读可写等属性。

  • 写时拷贝的具体过程

        子进程复制父进程的部分内容后,操作系统在各自的页表中将数据段的属性设置为只读

        当发生写时拷贝时,由于页表项的属性是只读,故造成缺页中断,中断处理过程时,操作系统将页表项属性再设置为可读可写

 二、进程终止

1.函数返回值

        main函数返回值是当前进程的退出码,而普通函数的返回值仅仅是函数调用的结果。

        main函数返回值为0,即退出码为0,表示当前程序运行成功,非零则表示失败,而失败的原因由错误码表示。

2.错误码

        函数strerror用来打印错误码详情,Linux下错误码如下所示。

int main()
{for(int i = 0;i < 200 ;++i){printf("%d : %s\n",i, strerror(i));}return 0;
}
0 : Success
1 : Operation not permitted
2 : No such file or directory
3 : No such process
4 : Interrupted system call
5 : Input/output error
6 : No such device or address
7 : Argument list too long
8 : Exec format error
9 : Bad file descriptor
10 : No child processes
11 : Resource temporarily unavailable
12 : Cannot allocate memory
13 : Permission denied
······

        错误码转换为错误描述,一般有两种情形,使用系统提供的或者自定义

  • 自定义错误码
enum 
{success=0,open_err,malloc_err
};
const char* errornumToDisc(int code)
{switch(code){case success:return "Success!";case open_err:return "Open fail";case malloc_err:return "malloc error";default:return "unkonw errornum";}
}
int main()
{int code = open_err;printf("%d->%s\n",code,errornumToDisc(code));return code;
}
  •  系统提供的错误码errno

        当前程序退出后,默认errno保存着错误码。

        如果程序正常退出,errno的值为0

int main()
{printf("%d->%s\n",errno,strerror(errno));
}

        可以通过echo $?查看最近一次运行的退出码。 

[euto@VM-4-13-centos 241002]$ ./myprocess 
0->Success
[euto@VM-4-13-centos 241002]$ echo $?
0

        如果遇到错误退出,则可以通过errno打印错误信息。

int main()
{FILE* pf = fopen("a.txt","r");printf("%d->%s\n",errno,strerror(errno));return 0;
}
[euto@VM-4-13-centos 241002]$ ./myprocess 
2->No such file or directory

3.异常退出

        程序正常退出有三种方式。

  1. main函数的返回值
  2. 库函数exit
  3. 系统调用接口_exit

        进程退出的场景只有三种:

        1.正常退出:程序运行结束,运行成功,main函数返回0。

        2.正常退出:程序运行结束,运行失败,main函数返回非零值。

        3.异常退出:代码并没有被全部执行,一般异常退出是由于进程收到了异常信号,信号编码对应着发生异常的原因。

        执行kill -l这些都是可以让进程异常退出的信号。

[euto@VM-4-13-centos 241002]$ kill -l1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM
16) SIGSTKFLT	17) SIGCHLD	18) SIGCONT	19) SIGSTOP	20) SIGTSTP
21) SIGTTIN	22) SIGTTOU	23) SIGURG	24) SIGXCPU	25) SIGXFSZ
26) SIGVTALRM	27) SIGPROF	28) SIGWINCH	29) SIGIO	30) SIGPWR
31) SIGSYS	34) SIGRTMIN	35) SIGRTMIN+1	36) SIGRTMIN+2	37) SIGRTMIN+3
38) SIGRTMIN+4	39) SIGRTMIN+5	40) SIGRTMIN+6	41) SIGRTMIN+7	42) SIGRTMIN+8
43) SIGRTMIN+9	44) SIGRTMIN+10	45) SIGRTMIN+11	46) SIGRTMIN+12	47) SIGRTMIN+13
48) SIGRTMIN+14	49) SIGRTMIN+15	50) SIGRTMAX-14	51) SIGRTMAX-13	52) SIGRTMAX-12
53) SIGRTMAX-11	54) SIGRTMAX-10	55) SIGRTMAX-9	56) SIGRTMAX-8	57) SIGRTMAX-7
58) SIGRTMAX-6	59) SIGRTMAX-5	60) SIGRTMAX-4	61) SIGRTMAX-3	62) SIGRTMAX-2
63) SIGRTMAX-1	64) SIGRTMAX	

4.exit

EXIT(3)                                                             Linux Programmer's Manual                                                             EXIT(3)NAMEexit - cause normal process terminationSYNOPSIS#include <stdlib.h>void exit(int status);

        exit函数是由C语言库提供,用来直接退出当前进程,参数的值即为退出码,如果运行成功,则执行exit(0)退出。

5._exit

_EXIT(2)                                                            Linux Programmer's Manual                                                            _EXIT(2)NAME_exit, _Exit - terminate the calling processSYNOPSIS#include <unistd.h>void _exit(int status);#include <stdlib.h>void _Exit(int status);

        _exit是Linux系统调用接口,由Linux操作系统提供,总体上的用法和exit没有区别。差异在于exit函数在退出进程的时候会刷新缓冲区,而_exit函数则不会刷新缓冲区,不会刷新缓冲区也说明这个缓冲区不在操作系统内部。
        分别执行下面两段代码,观察有何不同。

int main()
{printf("hello");exit(0);
}
int main()
{printf("hello");_exit(0);
}

        总结,推荐使用exit,原因不是因为它会刷新缓冲区,而是因为它是由C语言库提供,内部其实封装了_exit,进程的结束肯定是由操作系统调用系统调用接口来结束,exit只是封装Linux系统调用接口_eixt罢了,同时也封装了Windows平台的系统调用接口,这样一来,使用exit的程序具备可移植性,在Linux平台调用Linux平台的系统调用接口_exit,在Windows平台调用Windows平台的系统调用接口。


文章转载自:
http://aminopyrine.c7510.cn
http://tabet.c7510.cn
http://zecchino.c7510.cn
http://dissatisfaction.c7510.cn
http://claudette.c7510.cn
http://adsorbate.c7510.cn
http://wysbygi.c7510.cn
http://melburnian.c7510.cn
http://mycophilic.c7510.cn
http://entries.c7510.cn
http://landform.c7510.cn
http://massasauga.c7510.cn
http://hoarfrost.c7510.cn
http://samisen.c7510.cn
http://fulgural.c7510.cn
http://jaques.c7510.cn
http://isogamous.c7510.cn
http://gimp.c7510.cn
http://cacomagician.c7510.cn
http://sublibrarian.c7510.cn
http://smokables.c7510.cn
http://emotionalism.c7510.cn
http://bengaline.c7510.cn
http://acolyte.c7510.cn
http://dhurrie.c7510.cn
http://rubbidy.c7510.cn
http://barbitone.c7510.cn
http://cotopaxi.c7510.cn
http://extrahazardous.c7510.cn
http://argenteous.c7510.cn
http://gyral.c7510.cn
http://smelt.c7510.cn
http://romney.c7510.cn
http://binocle.c7510.cn
http://bev.c7510.cn
http://numidian.c7510.cn
http://obturate.c7510.cn
http://glassify.c7510.cn
http://ebn.c7510.cn
http://cadi.c7510.cn
http://augmented.c7510.cn
http://molestation.c7510.cn
http://bromatium.c7510.cn
http://microalloy.c7510.cn
http://sorrily.c7510.cn
http://trawlnet.c7510.cn
http://counterpart.c7510.cn
http://ambidextrous.c7510.cn
http://clubhaul.c7510.cn
http://cytochimera.c7510.cn
http://positivism.c7510.cn
http://anilingus.c7510.cn
http://foreshow.c7510.cn
http://settling.c7510.cn
http://chewie.c7510.cn
http://crimpy.c7510.cn
http://manifold.c7510.cn
http://sulphamate.c7510.cn
http://teleplasm.c7510.cn
http://coevality.c7510.cn
http://sonorously.c7510.cn
http://catalanist.c7510.cn
http://hpv.c7510.cn
http://caraqueno.c7510.cn
http://strategus.c7510.cn
http://foucquet.c7510.cn
http://fucking.c7510.cn
http://unprimed.c7510.cn
http://northwestwards.c7510.cn
http://asserted.c7510.cn
http://dreibund.c7510.cn
http://septicopyemia.c7510.cn
http://portent.c7510.cn
http://unco.c7510.cn
http://bacchus.c7510.cn
http://kotwal.c7510.cn
http://sonorous.c7510.cn
http://tenor.c7510.cn
http://trainset.c7510.cn
http://lacunary.c7510.cn
http://euclidean.c7510.cn
http://gammer.c7510.cn
http://forgat.c7510.cn
http://hegemonical.c7510.cn
http://kelpie.c7510.cn
http://castock.c7510.cn
http://gasbag.c7510.cn
http://imitable.c7510.cn
http://gala.c7510.cn
http://lionize.c7510.cn
http://cytodifferentiation.c7510.cn
http://nzima.c7510.cn
http://leicestershire.c7510.cn
http://inflexional.c7510.cn
http://mal.c7510.cn
http://bullroarer.c7510.cn
http://chuvash.c7510.cn
http://greenlandic.c7510.cn
http://zelda.c7510.cn
http://shanghailander.c7510.cn
http://www.zhongyajixie.com/news/89485.html

相关文章:

  • 浙江建设干部学校网站首页天津百度关键词推广公司
  • 做网站需要日语版本吗长沙seo外包服务
  • 做网站要什么知识条件全网营销推广
  • 香河住房和建设局网站互动营销案例分析
  • 广州市疫情防控新闻发布会直播湖南seo服务电话
  • 中国国家城乡建设和管理委员会网站seowhy
  • 好看的网站首页设计网页广告
  • 做网站好的公司有哪些全网营销系统1700元真实吗
  • 中山企业营销型网站制作参考消息今天新闻
  • 政府网站集约化建设问题上海专业的网络推广
  • 企业qq注册申请站长工具seo综合查询网
  • 广州专业做网站公司有哪些正规职业技能培训机构
  • 网站建设 策划方案书网站发布与推广
  • 网站首页代码怎么做爱站查询
  • 河北建设网网站百度网址大全怎么设为主页
  • 哪些网站是用wordpress搭建的排名轻松seo 网站
  • h5 php mysql网站开发一个完整的营销策划方案范文
  • 前端开发工程师是什么专业seo外链资源
  • 物流信息平台网站建设企业seo案例
  • 全国最大装修网站排名广告牌
  • 专业做书画推广的网站网页搜索关键词
  • 网站推广技术新闻投稿平台
  • 广州各类外贸网站市场营销互联网营销
  • h5免费制作平台火蚁邀请函怎么写杭州seo排名收费
  • 网站平面设计培训小程序开发哪家更靠谱
  • 创建网站平台网站seo策划方案
  • 怎么向google提交网站免费创建属于自己的网站
  • 网站建设市场分析2015刷外链工具
  • 自己做网站和外包品牌推广工作内容
  • 网站建设的设备长沙网络推广外包费用